示例#1
0
 function initMenu($id, $params)
 {
     $loadExtJs = (bool) $params->get('loadExtJS', true);
     $loadMethod = $params->get('loadMethod', 'ready');
     AriExtMenuHelper::loadAssets($loadExtJs);
     $defMenuConfig = array('direction' => 'horizontal', 'delay' => 0.2, 'autoWidth' => true, 'transitionType' => 'fade', 'transitionDuration' => 0.3, 'animate' => true);
     $config = array();
     foreach ($defMenuConfig as $key => $defValue) {
         $value = AriUtils::parseValueBySample($params->get($key, $defValue), $defValue);
         if ($value != $defValue) {
             $config[$key] = $value;
         }
     }
     $zIndex = intval($params->get('zIndex', -1), 10);
     if ($zIndex > 0) {
         $config['zIndex'] = $zIndex;
     }
     $doc =& JFactory::getDocument();
     if ($loadMethod == 'load') {
         $doc->addScriptDeclaration(sprintf(';Ext.EventManager.on(window, "load", function() { new Ext.ux.Menu("' . $id . '", %1$s); Ext.get("' . $id . '").select(".ux-menu-sub").removeClass("ux-menu-init-hidden"); });', AriJSONHelper::encode($config)));
     } else {
         $doc->addScriptDeclaration(sprintf(';(function() { var _menuInit = function() { new Ext.ux.Menu("' . $id . '", %1$s); Ext.get("' . $id . '").select(".ux-menu-sub").removeClass("ux-menu-init-hidden"); }; if (!Ext.isIE || typeof(MooTools) == "undefined" || typeof(MooTools.More) == "undefined") Ext.onReady(_menuInit); else window.addEvent("domready", _menuInit); })();', AriJSONHelper::encode($config)));
     }
     AriExtMenuHelper::addCustomStyles($id, $params);
 }
示例#2
0
 function replaceCallback($attrs, $content)
 {
     AriKernel::import('DocsViewer.DocsViewer');
     $params = $this->getParams($attrs, $content);
     $engine = AriUtils::getParam($attrs, 'engine', $this->_processParams->get('engine', 'iframe'));
     $model = AriDocsViewerHelper::getModel($engine);
     return $model ? $model->processContent($params, $content) : '';
 }
示例#3
0
 function getParameters($tag, $type = 'content')
 {
     global $database;
     $params = null;
     $plugin =& JPluginHelper::getPlugin($type, $tag);
     $params = new JParameter(AriUtils::getParam($plugin, 'params', ''));
     return $params;
 }
示例#4
0
 function getClientParams($params)
 {
     $clientParams = array('effect' => 'random', 'slices' => 15, 'animSpeed' => 500, 'pauseTime' => 3000, 'startSlide' => 0, 'directionNav' => true, 'directionNavHide' => true, 'controlNav' => true, 'keyboardNav' => true, 'pauseOnHover' => true, 'manualAdvance' => false, 'captionOpacity' => 0.8);
     $sliderParams = array();
     foreach ($clientParams as $key => $value) {
         $param = $params->get('opt_' . $key, null);
         if (is_null($param)) {
             continue;
         }
         $param = AriUtils::parseValueBySample($param, $value);
         if ($value !== $param) {
             $sliderParams[$key] = $param;
         }
     }
     return $sliderParams;
 }
	function getUserAlbumData($user, $album, $params)
	{
		$data = array();
		$options = array(
			'thumbsize' => AriUtils::getParam($params, 'thumbSize', 128),
			'imgmax' => AriUtils::getParam($params, 'imgSize', 1600));
		
		$maxResults = intval(AriUtils::getParam($params, 'count'), 10);
		if ($maxResults > 0) $options['max-results'] = $maxResults;
		
		$offset = intval(AriUtils::getParam($params, 'offset'), 10);
		if ($offset > 0) $options['start-index'] = $offset;
		
		$picasa =& $this->_picasa;
		
		$data = $picasa->getUserAlbumData($user, $album, $options);
		
		return $data;
	}
 function getClientParams($params)
 {
     $clientParams = array('minScale' => 0.5, 'reflHeight' => 0, 'reflGap' => 0, 'reflOpacity' => 0.0, 'xRadius' => 0.0, 'yRadius' => 0.0, 'xPos' => 0, 'yPos' => 0, 'FPS' => 30, 'speed' => 0.2, 'autoRotate' => 'no', 'autoRotateDelay' => 1500, 'mouseWheel' => false, 'reverseMouseWheel' => false, 'bringToFront' => false, 'keyboardNav' => false, 'reverseKeyboardNav' => false, 'startIndex' => 0, 'onlyFrontDescription' => false, 'disableTimer' => true, 'stopInBackground' => false);
     $sliderParams = array();
     foreach ($clientParams as $key => $value) {
         $param = $params->get('opt_' . $key, null);
         if (is_null($param)) {
             continue;
         }
         $param = AriUtils::parseValueBySample($param, $value);
         if ($value !== $param) {
             $sliderParams[$key] = $param;
         }
     }
     $width = intval($params->get('width', 300), 10);
     $height = intval($params->get('height'), 10);
     $isLiquidWidth = strpos($params->get('width'), '%') !== false;
     if (empty($sliderParams['xPos']) && !$isLiquidWidth) {
         $sliderParams['xPos'] = (int) ($width / 2);
     }
     if (empty($sliderParams['yPos'])) {
         $sliderParams['yPos'] = (int) ($height / 3);
     }
     if (empty($sliderParams['xRadius']) && !$isLiquidWidth) {
         $sliderParams['xRadius'] = (int) ($width / 2.3);
     }
     if (empty($sliderParams['yRadius'])) {
         $sliderParams['yRadius'] = (int) ($height / 6);
     }
     return $sliderParams;
 }
示例#7
0
	function initMenu($id, $menu, $currentMenu, $activeTopId, $hlCurrentItem, $params)
	{
		$safeMode = (bool)$params->get('safeMode', true);
		AriYUIMenuHelper::loadAssets($id, $safeMode);
		
		$menuId = $id . '_menu';
		$direction = $params->get('direction', 'horizontal');
		$isVertical = ($direction != 'horizontal');
		$selectedIndex = $hlCurrentItem 
			? AriYUIMenuHelper::getMenuItemIndex($menu, $currentMenu, $activeTopId, (bool)$params->get('showHiddenItems', false))
			: -1;

		$defMenuConfig = array(
			'zIndex' => 0,
			'classname' => '',
			'hidedelay' => 0,
			'maxheight' => 0,
			'minscrollheight' => 90,
			'scrollincrement' => 1,
			'showdelay' => 250
		);

		$config = array(
			'lazyLoad' => true, 
			'autosubmenudisplay' => true, 
			'position' => 'static'
		);
		foreach ($defMenuConfig as $key => $defValue)
		{
			$value = AriUtils::parseValueBySample($params->get($key, $defValue), $defValue);
			if ($value != $defValue) $config[$key] = $value;
		}
		
		$submenuAlign = $params->get('submenualignment');
		if (!empty($submenuAlign))
		{
			$submenuAlign = explode(',', $submenuAlign);
			$submenuAlign = array_map('trim', $submenuAlign);
	
			$config['submenualignment'] = $submenuAlign;	
		}
		
		$doc =& JFactory::getDocument();
		
		$doc->addScriptDeclaration(
			sprintf(
				'YAHOO.util.Event.onContentReady("' . $menuId . '", function () { var oMenu = new YAHOO.widget.%3$s("' . $menuId . '", %1$s); oMenu.render(); oMenu.show(); if (%2$d > -1) oMenu.getItem(%2$d).cfg.setProperty("selected", true); });',
				AriJSONHelper::encode($config),
				$selectedIndex,
				$isVertical ? 'Menu' : 'MenuBar'
			)
		);
		
		AriYUIMenuHelper::addCustomStyles($id, $params);
	}
示例#8
0
 function getClientParams($params)
 {
     $clientParams = array('effect' => 'random', 'slices' => 15, 'boxCols' => 8, 'boxRows' => 4, 'animSpeed' => 500, 'pauseTime' => 3000, 'startSlide' => 0, 'directionNav' => true, 'directionNavHide' => true, 'controlNav' => true, 'keyboardNav' => true, 'pauseOnHover' => true, 'manualAdvance' => false, 'captionOpacity' => 0.8, 'disableClick' => false, 'controlNavThumbs' => false, 'stopOnEnd' => false, 'randomStart' => false, 'responsive' => false);
     $sliderParams = array();
     foreach ($clientParams as $key => $value) {
         $param = $params->get('opt_' . $key, null);
         if (is_null($param)) {
             continue;
         }
         $param = AriUtils::parseValueBySample($param, $value);
         if ($value !== $param) {
             $sliderParams[$key] = $param;
         }
     }
     $showNav = $params->get('showNav');
     if (empty($showNav)) {
         $sliderParams['directionNav'] = false;
         $sliderParams['directionNavHide'] = false;
     } else {
         if ($showNav != 'onover') {
             $sliderParams['directionNavHide'] = false;
         }
     }
     $responsive = (bool) $params->get('responsive');
     if ($responsive) {
         $sliderParams['responsive'] = true;
     }
     return $sliderParams;
 }
	function execute($modelParams, $params, $templatePath)
	{
		$flickrProvider = new AriFlickrProvider($modelParams, null, 'mod_arisexylightbox');
		$flickrData = $this->getData(
			$flickrProvider->getData($modelParams),
			$modelParams, 
			$params);
		
		if ($modelParams['type'] == 'customtext')
		{
			$cId = uniqid('asb_', false);
			$modelParams['customtemplate'] = '<div id="' . $cId . '" style="cursor: pointer;">' . $modelParams['customtemplate'] . '</div>';
			$document =& JFactory::getDocument();
			$document->addScriptDeclaration(sprintf('jQuery(document).ready(function($){ $("#%1$s").click(function(event) { $("#%1$s").closest(".ari_lightbox_container").find("a[rel^=\'sexylightbox\']").eq(0).click(); }); });',
				$cId));			
		} 
		else if ($modelParams['type'] == 'flickrimage')
		{
			$photoId = $modelParams['flickrimage']['photoId'];
			$photo = AriUtils::getParam($flickrData['photos'], $photoId);
			$repeater = new AriRepeaterWebControl(ASEXYBOX_SINGLEIMAGEGALLERYTEMPLATE, $flickrData['photos']);

			AriTemplate::display(
				$templatePath . 'flickrimage.html.php', 
				array(
					'repeater' => $repeater, 
					'template' => AriSimpleTemplate::parse($modelParams['flickrimage']['template'], array('data' => $photo))
				)
			);
			return ;
		}
		else if ($modelParams['type'] == 'flickrphotosets')
		{
			$captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}');
			$needParseTemplate = strpos($captionTemplate, '{$') !== false;
			
			$firstPhotosetsPhoto = array();
			$photosetsPhoto = array();
			$modal = AriUtils2::parseValueBySample($params['_default']['modal'], false);
			
			foreach ($flickrData['photos'] as $dataItem)
			{
				$photosetId = $dataItem['photosetId'];
				$title = $needParseTemplate
					? AriSimpleTemplate::parse($captionTemplate, $dataItem, true)
					: $captionTemplate;
				if (!isset($firstPhotosetsPhoto[$photosetId]))
				{
					$photoset = AriUtils2::getParam($flickrData['photosets'], $photosetId);
					$aAttrs = array('href' => $dataItem['imgUrl'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[ps_' . $photosetId . ']', 'title' => $title);
					$imgAttrs = array('src' => $dataItem['thumbUrl'], 'border' => '0', 'alt' => $dataItem['Title']);
					$dataItem['Caption'] = AriUtils2::getParam($photoset, 'title', '');
					$dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>',
						AriHtmlHelper::getAttrStr($aAttrs),
						AriHtmlHelper::getAttrStr($imgAttrs));
					$firstPhotosetsPhoto[$photosetId] = $dataItem;
				}
				else
				{
					$aAttrs = array('href' => $dataItem['imgUrl'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[ps_' . $photosetId . ']', 'title' => $title);
					$dataItem['sexyimage'] = sprintf('<a%1$s></a>',
						AriHtmlHelper::getAttrStr($aAttrs));
					$photosetsPhoto[] = $dataItem;
				}
			}
			
			$showTitle = (bool)$modelParams['flickrphotosets']['showTitle'];
			$rptParams = $modelParams['flickrphotosets'];
			$rptParams['GalleryCaption'] = $showTitle ? '{$data:Caption}' : '';
			$repeater = new AriRepeaterWebControl(
				AriSimpleTemplate::parse(
					ASEXYBOX_SIMPLEGALLERYTEMPLATE,
					$rptParams
				), $firstPhotosetsPhoto);
			AriTemplate::display(
				$templatePath . 'flickrphotosets.html.php', 
				array(
					'repeater' => $repeater,
					'photos' => $photosetsPhoto
				)
			);
			return ;
		}
		
		parent::execute(
			$flickrData['photos'], 
			array(
				'simpleGallery' => ASEXYBOX_SIMPLEGALLERYTEMPLATE,
				'singleGallery' => ASEXYBOX_SINGLEIMAGEGALLERYTEMPLATE,
				'hiddenItems' => ASEXYBOX_HIDDENITEMSTEMPLATE,
				'slickGallery' => ASEXYBOX_SLICKGALLERYTEMPLATE),
			$modelParams,
			$params,
			$templatePath);
	}
	function getDifferences($deleteState = true)
	{
		$differences = array();
		$initState = $this->getInitState();

		$currentState = $this->getCurrentState();
		if ($currentState)
		{
			if (!empty($currentState['styleSheets']))
			{
				foreach ($currentState['styleSheets'] as $style => $styleInfo)
				{
					if (!array_key_exists($style, $initState['styleSheets']))
						$differences[] = sprintf('<link rel="stylesheet" href="%s" type="%s" />', $style, AriUtils::getParam($styleInfo, 'mime'));
				}
			}
			
			if (!empty($currentState['scripts']))
			{
				foreach ($currentState['scripts'] as $script => $type)
				{
					if (!array_key_exists($script, $initState['scripts']))
					{
						if (is_array($type))
							$type = $type['mime'];
						$differences[] = sprintf('<script type="%s" src="%s"></script>', $type, $script);
					}
				}
			}
			
			if (!empty($currentState['script']))
			{
				foreach ($currentState['script'] as $type => $script) 
				{
					if (!empty($initState['script'][$type]))
					{
						$difScript = '';
						if (strpos($script, $initState['script'][$type]) === 0)
							$difScript = trim(substr($script, strlen($initState['script'][$type])));
							
						if (!empty($difScript))
							$differences[] = sprintf('<script type="%s">%s</script>', $type, $difScript);
					}
					else
					{
						$differences[] = sprintf('<script type="%s">%s</script>', $type, $script);
					}
				}
			}
			
			if (!empty($currentState['custom']))
			{
				foreach ($currentState['custom'] as $customTag)
				{
					if (!in_array($customTag, $initState['custom']))
						$differences[] = $customTag;
				}
			}			
		}

		if ($deleteState) $this->deleteState();

		return $differences;
	}
示例#11
0
 function getFilteredParam($arr, $name, $defValue = null, $filterMask = 0)
 {
     $param = AriUtils::getParam($arr, $name, $defValue);
     return $param;
 }
示例#12
0
 * @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.');
$menuId = AriUtils::getParam($params, 'menuId');
$menu = AriUtils::getParam($params, 'menu');
$menuStartLevel = AriUtils::getParam($params, 'menuStartLevel');
$menuEndLevel = AriUtils::getParam($params, 'menuEndLevel');
$menuLevel = AriUtils::getParam($params, 'menuLevel');
$menuDirection = AriUtils::getParam($params, 'menuDirection');
$parent = AriUtils::getParam($params, 'parent');
$hlCurrentItem = AriUtils::getParam($params, 'hlCurrentItem');
$hlOnlyActiveItems = AriUtils::getParam($params, 'hlOnlyActiveItems');
$activeTopId = AriUtils::getParam($params, 'activeTopId');
$parentActiveTopId = AriUtils::getParam($params, 'parentActiveTopId');
$isMainLevel = $menuLevel == $menuStartLevel;
$ulClass = $isMainLevel ? 'ux-menu' : 'ux-menu-sub ux-menu-init-hidden';
if ($isMainLevel) {
    $ulClass .= $menuDirection == 'horizontal' ? ' ux-menu-horizontal' : ' ux-menu-vertical';
}
$currentLevelMenu = $menu->getItems(ARI_MENU_LEVEL_PARAM, $menuLevel);
?>

<?php 
if ($currentLevelMenu) {
    $parentParam = ARI_MENU_PARENT_PARAM;
    ?>
	<ul<?php 
    if ($isMainLevel) {
        ?>
示例#13
0
 public static function prepareSlides($slides, $params)
 {
     $newSlides = array();
     $target = $params->get('customLinkTarget');
     if (empty($target)) {
         $target = $params->get('linkTarget', '_self');
     }
     $defLink = $params->get('defaultLink');
     $baseUri = JURI::base(true);
     $lightboxEngine = self::getLightboxEngine($params);
     $lightboxGrouping = (bool) $params->get('lightbox_grouping', true);
     $lightboxGroup = $lightboxGrouping ? uniqid('cc_') : null;
     foreach ($slides as $slide) {
         $defSlideLink = str_replace('{$originalImage}', $slide['image'], $defLink);
         if (empty($slide['link'])) {
             if (!empty($defSlideLink)) {
                 $slide['link'] = $defSlideLink;
             } else {
                 if ($target != '_self' || $lightboxEngine) {
                     $slide['link'] = $baseUri . '/' . $slide['image'];
                 }
             }
         }
         $slideLink = AriUtils::getParam($slide, 'link');
         $isLink = !empty($slideLink);
         $description = isset($slide['description']) ? $slide['description'] : '';
         $altText = isset($slide['alt']) ? $slide['alt'] : '';
         $lnkAttrs = null;
         $imgAttrs = array('src' => $baseUri . '/' . $slide['image'], 'alt' => $altText, 'title' => $description, 'class' => 'imageslider-item');
         if (!empty($slide['width'])) {
             $imgAttrs['width'] = $slide['width'];
         }
         if (!empty($slide['height'])) {
             $imgAttrs['height'] = $slide['height'];
         }
         if ($isLink) {
             $lnkAttrs = array('href' => $slideLink, 'target' => $target);
             if ($description) {
                 $lnkAttrs['title'] = $description;
             }
             $skip_lb = false;
             if (!is_null($lightboxEngine) && strpos($slideLink, 'skip_lb') !== false) {
                 $uri = new JURI($slideLink);
                 $skip_lb = (bool) $uri->getVar('skip_lb');
                 $uri->delVar('skip_lb');
                 $slideLink = $uri->toString();
                 $lnkAttrs['href'] = $slideLink;
             }
             if (!$skip_lb && !is_null($lightboxEngine)) {
                 list($lnkAttrs, $imgAttrs) = $lightboxEngine->modifyAttrs($lnkAttrs, $imgAttrs, $lightboxGroup, $params);
             } else {
                 $originalLink = $slideLink;
                 if (strpos($originalLink, '_target') !== false) {
                     $uri = new JURI($originalLink);
                     $linkTarget = $uri->getVar('_target');
                     if (!is_null($linkTarget)) {
                         $uri->delVar('_target');
                         $lnkAttrs['target'] = $linkTarget;
                         $lnkAttrs['href'] = $uri->toString();
                     }
                 }
             }
         }
         $slide['lnkAttrs'] = $lnkAttrs;
         $slide['imgAttrs'] = $imgAttrs;
         $newSlides[] = $slide;
     }
     return $newSlides;
 }
	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;
	}
示例#15
0
$id = uniqid('asg_', false);
$repeater = $params['repeater'];
$modParams = $params['params'];

$slickGalleryPath = JPATH_ROOT . DS . 'modules' . DS . 'mod_arislickgallery' . DS . 'mod_arislickgallery' . DS . 'kernel' . DS . 'class.AriKernel.php';

require_once $slickGalleryPath;

AriKernel::import('SlickGallery.SlickGallery');

$sgParams = new JParameter('');
$sgParams->def('includeJQuery', '0');
$sgParams->def('width', intval($modParams['width'], 10));
$sgParams->def('height', intval($modParams['height'], 10));

$showTitle = (bool)AriUtils::getParam($modParams, 'showTitle', true);
if (!$showTitle)
{
	$cssStyles = '#' . $id . ' .arislickgallery-title{text-indent:-9999em}';

	$document =& JFactory::getDocument();
	$document->addStyleDeclaration($cssStyles);
}

AriSlickGalleryHelper::initGallery($id, $sgParams);
?>

<div class="ari-slick-gallery" id="<?php echo $id; ?>">
<?php
$repeater->render();
?>
示例#16
0
文件: menu.php 项目: emisdb/elyii
 * @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.');
$menuId = AriUtils::getParam($params, 'menuId');
$menu = AriUtils::getParam($params, 'menu');
$menuStartLevel = AriUtils::getParam($params, 'menuStartLevel');
$menuEndLevel = AriUtils::getParam($params, 'menuEndLevel');
$menuLevel = AriUtils::getParam($params, 'menuLevel');
$menuDirection = AriUtils::getParam($params, 'menuDirection');
$parent = AriUtils::getParam($params, 'parent');
$hlCurrentItem = AriUtils::getParam($params, 'hlCurrentItem');
$hlOnlyActiveItems = AriUtils::getParam($params, 'hlOnlyActiveItems');
$activeTopId = AriUtils::getParam($params, 'activeTopId');
$isMainLevel = $menuLevel == $menuStartLevel;
$ulClass = $isMainLevel ? 'ux-menu' : 'ux-menu-sub ux-menu-init-hidden';
if ($isMainLevel) {
    $ulClass .= $menuDirection == 'horizontal' ? ' ux-menu-horizontal' : ' ux-menu-vertical';
}
$currentLevelMenu = $menu->getItems(ARI_MENU_LEVEL_PARAM, $menuLevel);
?>

<?php 
if ($currentLevelMenu) {
    $parentParam = ARI_MENU_PARENT_PARAM;
    ?>
	<ul<?php 
    if ($isMainLevel) {
        ?>
	function getData($params)
	{
		$data = array();
		
		$prefix = $this->_prefix;
		$descrFile = $params['descrFile'];
		$thumbPath = $params['thumbPath'];
		$cacheDir = $this->_cacheDir;
		$cacheUri = $cacheDir;
		if (strpos($cacheUri, JPATH_ROOT . DS) === 0)
			$cacheUri = substr($cacheUri, strlen(JPATH_ROOT . DS));
		$cacheUri = str_replace(DS, '/', $cacheUri);
		
		$folders = $params['folders'];
		$thumbWidth = $params['thumbWidth'];
		$thumbHeight = $params['thumbHeight'];
		$sortBy = $params['sortBy'];
		$sortDir = $params['sortDir'];
		$thumbType = $params['thumbType'];
		$thumbTypeParams = $params['thumbTypeParams'];
		$thumbBehavior = $thumbType == 'resize' ? AriUtils::getParam($thumbTypeParams, 'behavior') : null;
		$emptyTitle = $params['emptyTitle'];
		$needProcessEmptyTitle = ($emptyTitle && strpos($emptyTitle, '{$') !== false);

		foreach ($folders as $folder)
		{
			$descriptions = $this->getDescriptions($descrFile, $folder);
			$files = $this->getImageFiles($folder, $params['fileFilter']);
			$inCSV = false;
			$folderData = array();
			foreach ($files as $file)
			{
				$dataItem = null;
				$fileUri = str_replace(DS, '/', $file);
				$filePath = JPATH_ROOT . DS . $file;
				$baseFileName = basename($file);
				$thumbImagePath = $thumbPath
					? JPATH_ROOT . DS . $folder . DS . str_replace('{$fileName}', $baseFileName, $thumbPath)
					: null;
				if ($thumbImagePath && file_exists($thumbImagePath) && is_readable($thumbImagePath))
				{
					$thumbSize = getimagesize($thumbImagePath);
					$dataItem = array(
						'image' => $fileUri,
						'thumb' => str_replace(DS, '/', $folder . DS . str_replace('{$fileName}', $baseFileName, $thumbPath)),
						'w' => $thumbSize[0],
						'h' => $thumbSize[1]
					);
				}
				else
				{
					$thumbSize = AriImageHelper::getThumbnailDimension($filePath, $thumbWidth, $thumbHeight, $thumbBehavior);
					$dataItem = array(
						'image' => $fileUri,
						'thumb' => $fileUri,
						'w' => $thumbSize['w'],
						'h' => $thumbSize['h']
					);
					
					if ($thumbSize['w'] && $thumbSize['h'])
					{
						$thumbFile = AriImageHelper::generateThumbnailFileName($prefix, $filePath, $thumbSize['w'], $thumbSize['h'], $thumbType);
						if (@file_exists($cacheDir . DS . $thumbFile))
							$dataItem['thumb'] = $cacheUri . '/' . $thumbFile;
					}
				}

				if (isset($descriptions[$baseFileName]))
				{
					$dataItem = array_merge($descriptions[$baseFileName], $dataItem);
					$inCSV = true;
				}
				
				if ($emptyTitle && empty($dataItem['Title']))
				{
					$title = $emptyTitle;
					if ($needProcessEmptyTitle)
					{
						$pathInfo = pathinfo($baseFileName);
						
						$title = AriSimpleTemplate::parse(
							$title, 
							array(
								'fileName' => $baseFileName,
								'baseFileName' => basename($baseFileName, '.' . $pathInfo['extension'])
							)
						);
					}
					
					$dataItem['Title'] = $title;
				}
				
				$key = $this->getDataItemKey($filePath, $baseFileName, $sortBy, $inCSV);
				if (empty($key))
					$folderData[$baseFileName] = $dataItem;
				else
					$folderData[$key] = $dataItem;
			}
			
			if (count($folderData) == 0)
				continue ;
				
			if ($inCSV && $sortBy == 'csv')
			{
				$tempData = array();
				
				foreach ($descriptions as $fileName => $value)
				{
					if (!isset($folderData[$fileName]))
						continue ;
						
					$tempData[] = $folderData[$fileName];
					unset($folderData[$fileName]);
				}
				
				if ($sortDir == 'desc')
					$tempData = array_reverse($tempData);

				$folderData = array_values($folderData);
				$folderData = array_merge($tempData, array_values($folderData));
			}
			else if ($sortBy != 'filename' && $sortBy != 'modified')
			{
				$folderData = array_values($folderData);
			}
				
			$data = array_merge($data, $folderData);
		}
		
		if ($sortBy && $sortBy != 'random' && $sortBy != 'csv')
		{
			if ($sortDir == 'asc')
				ksort($data);
			else
				krsort($data); 
		}

		return $data;
	}
示例#18
0
	function generateThumbnail($originalImgPath, $thumbDir, $prefix, $thumbWidth = 0, $thumbHeight = 0, $type = 'resize', $typeParams = array(), $filters = array())
	{
		$thumbSize = AriImageHelper::getThumbnailDimension($originalImgPath, $thumbWidth, $thumbHeight);
		if (!$thumbSize['w'] || !$thumbSize['h'] || !@is_readable($originalImgPath))
			return null;

		$width = $thumbSize['w'];
		$height = $thumbSize['h'];
		$path_parts = pathinfo($originalImgPath);

		$thumbName = AriImageHelper::generateThumbnailFileName($prefix, $originalImgPath, $width, $height, $type);
		$thumbImgPath = $thumbDir . DS . $thumbName;
		if (@file_exists($thumbImgPath) && @filemtime($thumbImgPath) > @filemtime($originalImgPath))
			return $thumbName;

		if (!AriImageHelper::initAsido())
			return ;
		$thumbImg = Asido::image($originalImgPath, $thumbImgPath);
		$needResize = true;		
		
		if ($type == 'crop')
		{
			Asido::crop(
				$thumbImg,
				intval(AriUtils::getParam($typeParams, 'x', 0), 10),
				intval(AriUtils::getParam($typeParams, 'y', 0), 10),
				$width ? $width : $height,
				$height ? $height : $width
			);
			$needResize = false;
		}
		else if ($type == 'cropresize')
		{
			Asido::crop(
				$thumbImg,
				intval(AriUtils::getParam($typeParams, 'x', 0), 10),
				intval(AriUtils::getParam($typeParams, 'y', 0), 10),
				intval(AriUtils::getParam($typeParams, 'width', 0), 10),
				intval(AriUtils::getParam($typeParams, 'height', 0), 10)
			);
		}

		if ($filters)
		{
			if (AriUtils::parseValueBySample(
					AriUtils::getParam($filters, 'grayscale', false),
					false)
				)
			{
				Asido::grayscale($thumbImg);
			}
			
			$rotateFilter = AriUtils::getParam($filters, 'rotate');
			if (is_array($rotateFilter) && 
				AriUtils::parseValueBySample(
					AriUtils::getParam($rotateFilter, 'enable', false),
					false)
				)
			{
				$angle = 0;
				$rotateType = AriUtils::getParam($rotateFilter, 'type', 'fixed');
				if ($rotateType == 'random')
				{
					$startAngle = intval(AriUtils::getParam($rotateFilter, 'startAngle', 0), 10);
					$endAngle = intval(AriUtils::getParam($rotateFilter, 'endAngle', 0), 10);
					$angle = rand($startAngle, $endAngle);
				}
				else
				{
					$angle = intval(AriUtils::getParam($rotateFilter, 'angle', 0), 10);
				}

				$angle = $angle % 360;
				if ($angle != 0)
				{
					Asido::rotate($thumbImg, $angle);
				}
			}
		}

		if ($needResize)
		{
			if (!$width)
				Asido::height($thumbImg, $height);
			else if (!$height)
				Asido::width($thumbImg, $width);
			else
				Asido::resize($thumbImg, $width, $height, ASIDO_RESIZE_STRETCH);
		}

		$thumbImg->save(ASIDO_OVERWRITE_ENABLED);
		
		return $thumbName;
	}
示例#19
0
	function getParameters($tag, $type = 'content')
	{
		global $database;

		$params = null;

		if (AriJoomlaBridge::isJoomla1_5())
		{
			$plugin =& JPluginHelper::getPlugin($type, $tag);
	    	$params = new JParameter(AriUtils::getParam($plugin, 'params', ''));
		}
		else
		{
			global $_MAMBOTS;
			
			$mambot = null;
			if (!isset($_MAMBOTS->_content_mambot_params[$tag]))
			{
				$query = sprintf('SELECT params FROM #__mambots WHERE element = %s AND folder = %s',
					$database->Quote($tag),
					$database->Quote($type));
			    $database->setQuery($query);
		    	$database->loadObject($mambot);
		    	
		    	$_MAMBOTS->_content_mambot_params[$tag] = $mambot;
			}
			else
			{
				$mambot = $_MAMBOTS->_content_mambot_params[$tag];
			}
	    	
	    	$params = new mosParameters(AriUtils::getParam($mambot, 'params', ''));
		}	

		return $params;
	}