Your IP : 216.73.216.219


Current Path : /home/pteabiscqq/www/modules/mod_jbcookies/
Upload File :
Current File : /home/pteabiscqq/www/modules/mod_jbcookies/mod_jbcookies.php

<?php
/**
 * @package			Joomla.Site
 * @subpackage		Modules - mod_jbcookies
 * 
 * @author			JoomBall! Project
 * @link			http://www.joomball.com
 * @copyright		Copyright © 2011-2018 JoomBall! Project. All Rights Reserved.
 * @license			GNU/GPL, http://www.gnu.org/licenses/gpl-3.0.html
 */

defined('_JEXEC') or die;

$domain = str_replace(array('https://www.', 'http://www.', 'https://', 'http://'), '', JUri::base());

if ((strpos($domain, '/') !== false) || (strstr($domain, 'localhost', true) !== false)) :
	$domain = '';
elseif ($params->get('subdomain_alias', 0) && count(explode('.', $domain)) > 1) :
	$parts = explode('.', $domain);
	$domain = $parts[count($parts) - 2] . '.' . $parts[count($parts) - 1];
else :
	$domain = '';
endif;

// Include jQuery
JHtml::_('jquery.framework');

// --> Afegeixo un arxiu d'estil
JHtml::_('stylesheet', 'modules/mod_jbcookies/assets/css/jbcookies.css', array('version' => 'auto'));

if ($params->get('color_option', 'selectable') == 'selectable') :
	$color_background = $params->get('color_background', 'black');
	$color_links = $params->get('color_links', 'blue');
else :
	$params->set('layout', 'default_custom'); // Modify view

	$color_background = $params->get('color_background_custom', '#000000');
	$color_links = $params->get('color_links_custom', '#37a4fc');
	$color_text = $params->get('color_text_custom', '#ffffff');
	$btn_border_color = $params->get('btn_border_color_custom', '#024175');
	$btn_text_color = $params->get('btn_text_color_custom', '#ffffff');
	$btn_start_color = $params->get('btn_start_bgcolor_custom', '#37a4fc');
	$btn_end_color = $params->get('btn_end_bgcolor_custom', '#025fab');
	$btn_width = (int) $params->get('btn_width_custom', '100');
	$btn_height = (int) $params->get('btn_height_custom', '30');
endif;

$position = $params->get('position', 'bottom');
$show_info = $params->get('show_info', 1);
$modal_framework = $params->get('modal', 'bootstrap');
$framework_version = $params->get('bootstrap_version', 2);
$show_article_modal = $params->get('show_article_modal', 1);
$moduleclass_sfx	= htmlspecialchars($params->get('moduleclass_sfx'));
$color_border = (strpos($color_links, 'btn-') !== false) ? ' border-' . ($position == 'top' ? 'bottom' : 'top') . ' border-' . str_replace('btn-', '', $color_links) : '';

$lang = JFactory::getLanguage();
$currentLang = $lang->getTag();
$langs = $params->get('lang');

$title			= $langs->$currentLang->title ? $langs->$currentLang->title : JText::_('MOD_JBCOOKIES_LANG_TITLE_DEFAULT');
$text			= $langs->$currentLang->text ? $langs->$currentLang->text : JText::_('MOD_JBCOOKIES_LANG_TEXT_DEFAULT');
$header			= $langs->$currentLang->header ? $langs->$currentLang->header : JText::_('MOD_JBCOOKIES_LANG_HEADER_DEFAULT');
$body			= $langs->$currentLang->body ? $langs->$currentLang->body : JText::_('MOD_JBCOOKIES_LANG_BODY_DEFAULT');
$aliasButton	= $langs->$currentLang->alias_button ? $langs->$currentLang->alias_button : JText::_('MOD_JBCOOKIES_GLOBAL_ACCEPT');
$aliasLink		= $langs->$currentLang->alias_link ? $langs->$currentLang->alias_link : JText::_('MOD_JBCOOKIES_GLOBAL_MORE_INFO');
$aLink			= $langs->$currentLang->alink;
$text_decline		= !empty($langs->$currentLang->text_decline) ? $langs->$currentLang->text_decline : JText::_('MOD_JBCOOKIES_LANG_TITLE_DEFAULT');
$aliasButton_decline= !empty($langs->$currentLang->alias_button_decline) ? $langs->$currentLang->alias_button_decline : JText::_('MOD_JBCOOKIES_GLOBAL_DECLINE');
$color_links_decline= $params->get('decline_btn_link_color', '#37a4fc');

if ($params->get('decline_icon', '')) {
	$aliasButton_decline= '<i class="hasTooltip '.$params->get('decline_icon', '').'" title="'.$aliasButton_decline.'"></i>';
	JHtml::_('bootstrap.tooltip');
}

if ($show_info && $aLink) {
	if ($show_article_modal) {
		// Join Model
		JModelLegacy::addIncludePath(JPATH_ROOT.'/components/com_content/models', 'ContentModel');
	
		// Get an instance of the generic articles model
		$model = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));
		$model->setState('filter.published', 1);
		
		$app = JFactory::getApplication('site');

		// Load the parameters.
		$paramsApp = $app->getParams();
		$model->setState('params', $paramsApp);

		// Filter by id
		$model->setState('article.id', (int) $aLink);

		// Retrieve Content
		$item = $model->getItem();

		if (!empty($item->params) && is_object($item->params)) {
			$showInfo = ($item->params->get('show_intro', '1') == '1') ? 1 : 0;
		} else {
			$paramsContent = JComponentHelper::getParams('com_content');
			$showInfo = ($paramsContent->get('show_intro', '1') == '1') ? 1 : 0;
		}
		
//			echo '<pre>'; echo print_r($paramsContent); echo '</pre>'; exit;
		
		if ($showInfo)
		{
			$item->text = $item->introtext . ' ' . $item->fulltext;
		}
		elseif ($item->fulltext)
		{
			$item->text = $item->fulltext;
		}
		else
		{
			$item->text = $item->introtext;
		}
		
		$aLink = 0;
		$show_info = 1;
		$header = $item->title;
		$body = $item->text;
		
		if ($modal_framework == 'bootstrap' && $framework_version == 2) { // Bootstrap 2.3.2
			// Load the modal behavior script.
			JHtml::_('behavior.modal', 'a.jbcookies');
		}
	} else {
		$db		= JFactory::getDbo();
		$query	= $db->getQuery(true);
		
		$query->select('a.id, a.alias, a.catid');
		$query->from('#__content AS a');
		
		// Join on category table.
		$query->select('c.alias AS category_alias')
			->join('LEFT', '#__categories AS c on c.id = a.catid');
			
		// Join over the categories to get parent category titles
		$query->select('parent.id as parent_id, parent.alias as parent_alias')
			->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
			
		$query->where('a.id = '.(int) $aLink);
		// Get the options.
		$db->setQuery((string)$query);
		$item = $db->loadObject();
		
		// Add router helpers.
		$item->slug			= $item->alias ? ($item->id.':'.$item->alias) : $item->id;
		$item->catslug		= $item->category_alias ? ($item->catid.':'.$item->category_alias) : $item->catid;
		$item->parent_slug	= $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
	
		// No link for ROOT category
		if ($item->parent_alias == 'root')
		{
			$item->parent_slug = null;
		}
	
		require_once JPATH_BASE.'/components/com_content/helpers/route.php';
		
		$item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
	}
} else {
	if ($modal_framework == 'bootstrap' && $framework_version == 2) { // Bootstrap 2.3.2
		// Load the modal behavior script.
		JHtml::_('behavior.modal', 'a.jbcookies');
	}
}

require JModuleHelper::getLayoutPath('mod_jbcookies', $params->get('layout', 'default'));
?>
<script type="text/javascript">
    jQuery(document).ready(function () { 
    	function setCookie(c_name,value,exdays,domain) {
			if (domain != '') {domain = '; domain=' + domain}

			var exdate=new Date();
			exdate.setDate(exdate.getDate() + exdays);
			var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()) + "; path=/" + domain;

			document.cookie=c_name + "=" + c_value;
		}

		var $jb_cookie = jQuery('.jb-cookie'),
			cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)jbcookies\s*\=\s*([^;]*).*$)|^.*$/, "$1");

		if (cookieValue === '') { // NO EXIST
			$jb_cookie.delay(1000).slideDown('fast');
		<?php if ($params->get('show_decline', 1)) : ?>
			} else { // YES EXIST
				jQuery('.jb-cookie-decline').fadeIn('slow', function() {});
		<?php endif; ?>
		}

		jQuery('.jb-accept').click(function() {
			setCookie("jbcookies","yes",<?php echo $params->get('duration_cookie_days', 90); ?>,"<?php echo trim($domain); ?>");
			$jb_cookie.slideUp('slow');
			<?php if ($params->get('show_decline', 1)) : ?>
				jQuery('.jb-cookie-decline').fadeIn('slow', function() {});
			<?php endif; ?>
		});

		jQuery('.jb-decline').click(function() {
			jQuery('.jb-cookie-decline').fadeOut('slow', function() {
				<?php if ($params->get('show_decline', 1) && $modal_framework == 'bootstrap' && $framework_version != 5) : ?>
					jQuery('.jb-cookie-decline').find('.hasTooltip').tooltip('hide');
				<?php endif; ?>
			});
			setCookie("jbcookies","",0,"<?php echo trim($domain); ?>");
			$jb_cookie.delay(1000).slideDown('fast');
		});
    });
</script>