function getUniqueOverrideParameters($srcParams, $overrideParams, $caseInsensitive = false)
	{
		$uniqueParams = array();
		
		foreach ($srcParams as $srcKey => $srcValue)
		{
			if (is_array($srcValue))
			{
				if (isset($overrideParams[$srcKey]) || ($caseInsensitive && isset($overrideParams[strtolower($srcKey)])))
				{
					$subParams = AriParametersHelper::getUniqueOverrideParameters(
						$srcValue, 
						isset($overrideParams[$srcKey]) ? $overrideParams[$srcKey] : $overrideParams[strtolower($srcKey)],
						$caseInsensitive);
					if (count($subParams) > 0)
						$uniqueParams[$srcKey] = $subParams;
				}
			}
			else if (array_key_exists($srcKey, $overrideParams) || ($caseInsensitive && array_key_exists(strtolower($srcKey), $overrideParams)))
			{
				$overrideValue = AriUtils2::parseValueBySample(
					isset($overrideParams[$srcKey]) ? $overrideParams[$srcKey] : $overrideParams[strtolower($srcKey)], 
					$srcValue);
				if ($overrideValue != $srcValue)
					$uniqueParams[$srcKey] = $overrideValue; 
			}
		}
		
		return $uniqueParams;
	}
	function execute($modelParams, $params, $templatePath)
	{
		$module =& AriModuleHelper::getModuleById(AriUtils2::getParam($modelParams, 'id'));
		if (empty($module))
			return ;
			
		$content = AriModuleHelper::renderModule($module);
		if (empty($content))
			return ;

		$modelParams['text'] = $content;
		$modelParams['modal'] = $params['_default']['modal'];
		$modelParams['group'] = $params['_default']['groupName'];
		$modelParams['bgColor'] = isset($params['_default']['bgColor']) ? $params['_default']['bgColor'] : '';
		
		parent::execute($modelParams, $params, $templatePath);
	}
	function inlineGalleryUpdateCallback($content, $images, $params)
	{
		$thumbCount = $params['thumbCount'];
		$single = $params['single'];
		$groupName = !$single ? AriUtils2::getParam($this->_params['_default'], 'groupName') : null;
		$modal = AriUtils2::parseValueBySample($this->_params['_default']['modal'], false);
		for ($i = 0; $i < count($images); $i++)
		{
			$relAttr = 'sexylightbox' . ($groupName ? '[' . $groupName . ']' : '');
			$image =& $images[$i];
			$image['image']['attributes']['rel'] = $relAttr;
			$image['image']['attributes']['src'] = $image['image']['src'] . ($modal ? '?modal=1' : '');
			if ($thumbCount > 0 && $i >= $thumbCount)
				$image['image']['attributes']['style'] = 'display: none;';
		}

		return AriInlineThumbnailProvider::updateCallback($content, $images, $params);
	}	
	function getData($picasaData, $modelParams, $params)
	{
		$data = array();
		if (empty($picasaData))
			return $data;
		
		$group = $params['_default']['groupName'];
		if (empty($group)) $group = uniqid('asexy_');
		$modal = AriUtils2::parseValueBySample($params['_default']['modal'], false);
		$keepSize = AriUtils2::getParam($modelParams, 'keepSize', false);
		
		$captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}');
		$needParseTemplate = strpos($captionTemplate, '{$') !== false;
		
		foreach ($picasaData as $key => $value)
		{
			$dataItem = $value;

			$dataItem['Title'] = AriUtils2::getParam($dataItem, 'summary', '');
			$title = $needParseTemplate
				? AriSimpleTemplate::parse($captionTemplate, $dataItem, true)
				: $captionTemplate;
			$img = $dataItem['image'];
			$thumb = $dataItem['thumb'];
			$aAttrs = array('href' => $img['url'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title);
			$imgAttrs = array('src' => $thumb['url'], 'border' => '0', 'alt' => $dataItem['Title'], 'width' => $thumb['w'], 'height' => $thumb['h']);
			
			if ($keepSize)
			{
				$aAttrs['href'] .= $modal ? '&' : '?';
				$aAttrs['href'] .= 'width=' . $img['w'] . '&height=' . $img['h'];
			}

			$dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>',
					AriHtmlHelper::getAttrStr($aAttrs),
					AriHtmlHelper::getAttrStr($imgAttrs));
					
			$data[$key] = $dataItem;
		}

		return $data;
	}
	function getIdList($modelParams)
	{
		$articleIdList = array();
		$tempIdList = AriUtils2::getParam($modelParams, 'id');
		$tempIdList = preg_split("/[\s,;]+/i", $tempIdList);
		if (empty($tempIdList))
			return $articleIdList;
			
		foreach ($tempIdList as $id)
		{
			if (empty($id))
				continue ;

			$articleId = intval($id, 10);
			if ($articleId > 0)
				$articleIdList[] = $articleId;
		}

		return $articleIdList;
	}
Example #6
0
	function _handleError($response, $params, $options)
	{
		$error = null;
		switch ($response)
		{
			case ARI_PICASA_ERROR_NOALBUM:
				$error = sprintf('Picasa album "%1$s" not found.',
					AriUtils2::getParam($params, 'album'));
				break;
		}
		
		if ($error)
			$this->setError($error);
	}
	function getPhotoHeight($data, $type)
	{
		$type = $this->getShortImageType($type);
		
		return intval(AriUtils2::getParam($data, 'height_' . $type), 10);
	}
	function getCorrectedParameters($params)
	{
		$clearParams = array(
			'thumbWidth' => 150,
			'thumbHeight' => 0,
			'generateThumbs' => true,
			'thumbCount' => 0,
			'single' => false,
			'class' => '',
			'groupName' => uniqid('app_', false),
			'ignoreEmptyDim' => false,
			'ignoreRemote' => false
		);
		
		$correctedParams = array();
		foreach ($clearParams as $key => $value)
		{
			$correctedParams[$key] = AriUtils2::parseValueBySample(
				AriUtils2::getParam($params, $key, $value),
				$value);			
		}
		
		$correctedParams = array_merge($correctedParams, array_diff($params, $correctedParams));
		unset($correctedParams['content']);
		
		$thumbType = strtolower(AriUtils2::getParam($params, 'thumbType', 'resize'));
		if (!in_array($thumbType, array('resize', 'crop', 'cropresize')))
			$thumbType = 'resize';
			
		$thumbTypeParamKey = 'thumbType' . ucfirst($thumbType);
		$correctedParams['thumbTypeParams'] = AriUtils2::getParam($params, $thumbTypeParamKey, array());
		$correctedParams['thumbType'] = $thumbType;
		if (!isset($correctedParams['thumbFilters']))
			$correctedParams['thumbFilters'] = array();
		
		return $correctedParams;
	}
	function getData($flickrData, $modelParams, $params)
	{
		$data = array('photos' => array(), 'photosets' => array());
		if (empty($flickrData))
			return $data;
		
		$group = $params['_default']['groupName'];
		if (empty($group)) $group = uniqid('asexy_');
		$modal = AriUtils2::parseValueBySample($params['_default']['modal'], false);
		
		$captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}');
		$needParseTemplate = strpos($captionTemplate, '{$') !== false;

		$photos = AriUtils2::getParam($flickrData, 'photos', $flickrData);
		foreach ($photos as $key => $value)
		{
			$dataItem = $value;

			$title = $needParseTemplate
				? AriSimpleTemplate::parse($captionTemplate, $dataItem, true)
				: $captionTemplate;
			$aAttrs = array('href' => $dataItem['imgUrl'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title);
			$imgAttrs = array('src' => $dataItem['thumbUrl'], 'border' => '0', 'alt' => $dataItem['Title']);

			$dataItem['thumb'] = $dataItem['thumbUrl'];
			$dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>',
					AriHtmlHelper::getAttrStr($aAttrs),
					AriHtmlHelper::getAttrStr($imgAttrs));
					
			$data['photos'][$key] = $dataItem;
		}
		
		$data['photosets'] = AriUtils2::getParam($flickrData, 'photosets', array());

		return $data;
	}
Example #10
0
$title = str_replace('"', '&quot;', AriUtils2::getParam($params, 'title', ''));
$url = AriUtils2::getParam($params, 'url', '');
$class = AriUtils2::getParam($params, 'class', '');
$modal = AriUtils2::getParam($params, 'modal', false);
$group = AriUtils2::getParam($params, 'group', false);
$bgColor = AriUtils2::getParam($params, 'bgColor', false);
$idList = AriUtils2::getParam($params, 'idList', array());
$width = AriUtils2::getParam($params, 'width', 350);
$height = AriUtils2::getParam($params, 'height', 125);

if (is_array($idList) && count($idList) > 0):
	$firstArticle = true;
	foreach ($idList as $id):
		$url = sprintf(JURI::root(true) . '/index.php?option=com_content&amp;view=article&amp;tmpl=component&amp;id=%d&amp;TB_iframe=1&amp;width=%s&amp;height=%s%s%s',
			$id,
			$width,
			$height,
			$modal ? '&amp;modal=1' : '',
			$bgColor ? '&amp;background=' . $bgColor : '');
?>

<a class="sexy-link<?php if ($class) echo ' ' . $class; ?>" href="<?php echo $url; ?>" rel="sexylightbox<?php if ($group): ?>[<?php echo $group; ?>]<?php endif; ?>" title="<?php echo $title; ?>"<?php if (!$firstArticle): ?> style="display: none;"<?php endif; ?>>
	<?php echo $firstArticle ? AriUtils2::getParam($params, 'link') : ''; ?>
</a>

<?php
		$firstArticle = false;
	endforeach;
endif;
?>
	function getParamValue($key, $params)
	{
		$value = null;
		
		if (!$key) return $value;
		
		$keys = array();
		if (strpos($key, ':') !== false)
		{
			$keys = explode(':', $key);
		}
		else
		{
			$keys = array($key);
		}
		
		$value = $params;
		$isLight = class_exists('AriUtils2');
		foreach ($keys as $cKey)
		{
			$value = $isLight
				? AriUtils2::getParam($value, $cKey, null)
				: AriUtils::getParam($value, $cKey, null);

			if (is_null($value)) break;
		}
		
		if (is_array($value)) $value = null;

		return $value;
	}
$groupName = $params->get('groupName');
$thumbQuality = intval($params->get('thumbQuality', 80), 10);
if (!defined('ASIDO_GD_JPEG_QUALITY'))
	define('ASIDO_GD_JPEG_QUALITY', $thumbQuality);

if (empty($groupName)) $params->set('groupName', uniqid('asexy_'));
$autoShow = $params->get('autoShow');
$showOnClose = $params->get('showOnClose');
$mParams = AriParametersHelper::flatParametersToArray($params);
AriSexyLightboxHelper::includeAssets(
	AriUtils2::parseValueBySample($params->get('includeJQuery'), true),
	AriUtils2::parseValueBySample($params->get('noConflict'), true),
	AriUtils2::parseValueBySample($params->get('jQueryVer', '1.4.4'), '1.4.4'),
	AriUtils2::getParam($mParams, 'opt', array()));

AriSexyLightboxHelper::activateAutoShow(
	trim($params->get('groupName', '')), 
	$autoShow, 
	$params->get('unique', 'aslmod_' . $module->id),
	AriUtils2::getParam($mParams, 'cookie'));
	
AriSexyLightboxHelper::activateAutoShowOnClose(
	trim($params->get('groupName', '')),
	$params->get('onCloseMessage'), 
	$showOnClose, 
	$params->get('unique', 'aslmod_' . $module->id),
	AriUtils2::getParam($mParams, 'cookie'));

$activeType = $params->get('activeType', 'imagelist');
AriSexyLightboxHelper::executeModel($activeType, $mParams, dirname(__FILE__) . DS . 'includes' . DS . 'templates' . DS);
?>
Example #13
0
<?php
/*
 * ARI Sexy Lightbox Joomla! module
 *
 * @package		ARI Sexy Lightbox Joomla! module.
 * @version		1.0.0
 * @author		ARI Soft
 * @copyright	Copyright (c) 2009 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 * 
 */

defined('ARI_FRAMEWORK_LOADED') or die('Direct Access to this location is not allowed.');

$contentId = uniqid('asl', false);
$width = AriUtils2::getParam($params, 'width', 350);
$height = AriUtils2::getParam($params, 'height', 125);
$class = AriUtils2::getParam($params, 'class', '');
$title = str_replace('"', '&quot;', AriUtils2::getParam($params, 'title', ''));
$modal = AriUtils2::getParam($params, 'modal', false);
$group = AriUtils2::getParam($params, 'group', false);
$bgColor = AriUtils2::getParam($params, 'bgColor', false);
$wrapTag = AriUtils2::getParam($params, 'wrapTag', 'div');
if (empty($wrapTag)) $wrapTag = 'div';
?>

<<?php echo $wrapTag; ?> id="<?php echo $contentId; ?>" style="display: none;"><?php echo AriUtils2::getParam($params, 'text'); ?></<?php echo $wrapTag; ?>> 
<a class="sexy-link<?php if ($class) echo ' ' . $class; ?>" href="#TB_inline?inlineId=<?php echo $contentId; ?>&amp;height=<?php echo $height; ?>&amp;width=<?php echo $width; ?><?php if ($modal): ?>&amp;modal=1<?php endif; ?><?php if ($bgColor): ?>&amp;background=<?php echo $bgColor; ?><?php endif; ?>" rel="sexylightbox<?php if ($group): ?>[<?php echo $group; ?>]<?php endif; ?>" title="<?php echo $title; ?>">
<?php echo AriUtils2::getParam($params, 'link'); ?>
</a>
	function modifyData(&$data, $params, $modelParams)
	{
		$rootUri = JURI::root(true) . '/';
		$keepSize = AriUtils2::getParam($modelParams, 'keepSize', false);
		$target = AriUtils2::getParam($modelParams, 'target');
		if ($target == '_self')
			$target = null;
		
		$group = $params['_default']['groupName'];
		if (empty($group)) $group = uniqid('asexy_');
		$modal = AriUtils2::parseValueBySample($params['_default']['modal'], false);
		
		$captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}');
		$needParseTemplate = strpos($captionTemplate, '{$') !== false;
		
		foreach ($data as $key => $value)
		{
			$dataItem =& $data[$key];
			
			$img = $dataItem['image'];
			$title = $needParseTemplate
				? AriSimpleTemplate::parse($captionTemplate, $dataItem, true)
				: $captionTemplate;
			$aAttrs = array('href' => $rootUri . $img . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title);
			if ($target)
				$aAttrs['target'] = $target;
			if ($keepSize)
			{
				$size = @getimagesize(JPATH_ROOT . DS . $img);
				if (!empty($size) &&  count($size) > 1)
				{
					 $aAttrs['href'] .= $modal ? '&' : '?';
					 $aAttrs['href'] .= 'width=' . $size[0] . '&height=' . $size[1];
				}
			}
			
			$imgAttrs = array('src' => $rootUri . $dataItem['thumb'], 'border' => '0', 'alt' => str_replace('"', '&qout;', AriUtils2::getParam($dataItem, 'Title', '')));
			if ($dataItem['w']) $imgAttrs['width'] = $dataItem['w'];
			if ($dataItem['h']) $imgAttrs['height'] = $dataItem['h'];
			if (!empty($dataItem['Link'])) $imgAttrs['longdesc'] = $dataItem['Link'];
			$dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>',
				AriHtmlHelper::getAttrStr($aAttrs),
				AriHtmlHelper::getAttrStr($imgAttrs));
		}
	}	
	function activateAutoShowOnClose($group = '', $message = '', $autoShow = true, $uniqueKey = false, $cookie = null)
	{
		if ($autoShow != 'first')
			$autoShow = AriUtils2::parseValueBySample($autoShow, false);
		
		if (!$autoShow)
			return ;
			
		static $loaded;
		
		if ($loaded)
			return ;

		if ('first' === $autoShow && !empty($uniqueKey))
		{
			$cookieKey = 'asl_' . $uniqueKey;
			$cookieDuration = intval(AriUtils2::getParam($cookie, 'duration', 365), 10) * 24 * 60 * 60;

			if ($cookieDuration == 0)
			{
			 	if (!empty($_SESSION[$cookieKey]))
					return ;
					
				$_SESSION[$cookieKey] = true;
			}	
			else
			{
				if (!empty($_COOKIE[$cookieKey]))
					return ;

				setcookie($cookieKey, '1', time() + $cookieDuration);
			}
		}
		
		AriSexyLightboxHelper::includeTools();
		$document =& JFactory::getDocument();
		$document->addScriptDeclaration(sprintf('ARISexyLightboxTools.initBeforeUnload("a[rel^=\'%1$s\']:eq(0)", "%2$s");',
			$group 
				? 'sexylightbox[' . $group . ']'
				: 'sexylightbox',
			addcslashes($message, '"')));
		
		$loaded = true;
	}
Example #16
0
	function replaceCallback($attrs, $content = '')
	{
		$this->_columnCount = intval(AriUtils2::getParam($attrs, 'itemCount', 1), 10);
		$rowClasses = AriUtils2::getParam($attrs, 'rowClass', '');
		$rowClasses = explode(';', $rowClasses);
		array_walk($rowClasses, 'trim');
		$this->_rowClasses = $rowClasses;
		
		parent::replaceCallback($attrs, $content);
	}
Example #17
0
	function parseValueBySample($str, $sample)
	{
		return AriUtils2::parseValue($str, gettype($sample));
	}
	function getCorrectedParameters($params)
	{
		$thumbWidth = intval(AriUtils2::getParam($params, 'thumbWidth', 0), 10);
		if ($thumbWidth < 0) $thumbWidth = 0;

		$thumbHeight = intval(AriUtils2::getParam($params, 'thumbHeight', 0), 10);
		if ($thumbHeight < 0) $thumbHeight = 0;
		
		$cachePeriod = intval(AriUtils2::getParam($params, 'cachePeriod', 0), 10);
		if ($cachePeriod < 0) $cachePeriod = 0;
		
		$generateThumbs = (($thumbWidth || $thumbHeight) && AriAsidoHelper::isExtensionLoaded())
			? AriUtils2::parseValueBySample(AriUtils2::getParam($params, 'generateThumbs'), false)
			: false;

		$scanSubFolders = AriUtils2::parseValueBySample(AriUtils2::getParam($params, 'subdir'), false);
		$folders = $this->getFolders(trim(AriUtils2::getParam($params, 'dir', '')), $scanSubFolders);
		
		$thumbPath = trim(AriUtils2::getParam($params, 'thumbPath', ''));
		if ($thumbPath)
			$thumbPath = preg_replace('#^[/\\\\]+|[/\\\\]+$#', '', JPath::clean($thumbPath));
			
		$sortDir = strtolower(AriUtils2::getParam($params, 'sortDir', 'asc'));
		if (!in_array($sortDir, array('asc', 'desc')))
			$sortDir = 'asc';

		$thumbType = strtolower(AriUtils2::getParam($params, 'thumbType', 'resize'));
		if (!in_array($thumbType, array('resize', 'crop', 'cropresize')))
			$thumbType = 'resize';
			
		$thumbTypeParamKey = 'thumbType' . ucfirst($thumbType);
		$thumbTypeParams = AriUtils2::getParam($params, $thumbTypeParamKey, array());

		return array(
			'key' => $params['key'],
			'checkSum' => $params['checkSum'],
			'descrFile' => trim(AriUtils2::getParam($params, 'descrFile', '')),
			'fileFilter' => $params['fileFilter'],
			'thumbWidth' => $thumbWidth,
			'thumbHeight' => $thumbHeight,
			'generateThumbs' => $generateThumbs,
			'thumbType' => $thumbType,
			'thumbTypeParams' => $thumbTypeParams,
			'thumbFilters' => AriUtils2::getParam($params, 'thumbFilters', array()),
			'folders' => $folders,
			'cachePeriod' => $cachePeriod,
			'thumbPath' => $thumbPath,
			'sortDir' => $sortDir,
			'sortBy' => strtolower(AriUtils2::getParam($params, 'sortBy', '')),
			'emptyTitle' => AriUtils2::getParam($params['simplegallery'], 'emptyTitle', '')
		);
	}