function render($params)
 {
     global $mainframe;
     $document = JFactory::getDocument();
     $URLOriginal = JURI::root();
     $module_base = $URLOriginal . 'modules/mod_nivoslider/assets/';
     if ($params->get('jQuery', '1')) {
         JFactory::getDocument()->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js');
         JFactory::getDocument()->addScriptDeclaration("jQuery.noConflict();");
     }
     JHTML::script('jquery.nivo.slider.js', $module_base);
     $customStyle = "/* Nivo-Szaki Slider custom style */\n";
     $moduleclassSfx = 'NivoSzakiSlider';
     if ($params->get('moduleclass_sfx', '')) {
         $moduleclassSfx = $params->get('moduleclass_sfx', '');
     }
     $imagesDir = rtrim($params->get('imagesDir', 'images/banners/'), '/\\');
     $subDir = $params->get('subDir', 0);
     $document->addStyleSheet($module_base . 'nivo-slider.css', 'text/css', 'screen');
     $document->addStyleSheet($module_base . 'default/default.css', 'text/css', 'screen');
     $document->addStyleSheet($module_base . 'orman/orman.css', 'text/css', 'screen');
     $document->addStyleSheet($module_base . 'pascal/pascal.css', 'text/css', 'screen');
     if ($params->get('customStyle')) {
         $customStyle = trim($params->get('customStyle'));
     }
     $soundFX = $params->get('soundFX', 0);
     $soundVol = $params->get('soundVol', 1);
     $sound = $module_base . $params->get('sound', 'nivo-szakislider.ogg');
     $jsSoundFX = '';
     if ($soundFX) {
         $jsSoundFX = "if (audSprt) soundFX.play();";
         $document->addScriptDeclaration("\r\r\n\t\t\tvar audSprt = !!(document.createElement('audio').canPlayType);\r\r\n\t\t\tif (audSprt) {\r\r\n\t\t\tsoundFX = new Audio('{$sound}');\r\r\n\t\t\tsoundFX.preload = true;\r\r\n\t\t\tsoundFX.volume={$soundVol};\r\r\n\t\t\t}\r\r\n\t\t\t");
     }
     $effect = $params->get('effect', 'random');
     $slices = $params->get('slices', '15');
     $boxCols = $params->get('boxCols', '8');
     $boxRows = $params->get('boxRows', '4');
     $animSpeed = $params->get('animSpeed', 500);
     $pauseTime = $params->get('pauseTime', 3000);
     $startSlide = $params->get('startSlide', 0);
     $imagesAttributes = $params->get('imagesAttributes', '');
     $target = $params->get('target', '_self');
     $directionNav = $params->get('directionNav', 1);
     $directionNavHide = $params->get('directionNavHide', 1);
     $controlNav = $params->get('controlNav', 1);
     $controlNavThumbs = $params->get('controlNavThumbs', 0);
     $controlNavThumbsSearch = $params->get('controlNavThumbsSearch', '.jpg');
     $controlNavThumbsReplace = $params->get('controlNavThumbsReplace', '_thumb.jpg');
     $keyboardNav = $params->get('keyboardNav', 1);
     $pauseOnHover = $params->get('pauseOnHover', 1);
     $manualAdvance = $params->get('manualAdvance', 0);
     $captionOpacity = $params->get('captionOpacity', '0.8');
     $prevText = $params->get('prevText', 'Prev');
     $nextText = $params->get('nextText', 'Next');
     $randomStart = $params->get('randomStart', 'false');
     $display = true;
     $document->addScriptDeclaration("\r\r\n            (function(\$) {\r\r\n                \$(window).load(function(){\r\r\n                    \$('." . str_replace(' ', '.', $moduleclassSfx) . " .nivoSlider').nivoSlider({\r\r\n                    effect:'{$effect}',\r\r\n                    slices:{$slices},\r\r\n                    boxCols:{$boxCols},\r\r\n                    boxRows:{$boxRows},\r\r\n                    animSpeed:{$animSpeed},\r\r\n                    pauseTime:{$pauseTime},\r\r\n                    startSlide:{$startSlide},\r\r\n                    beforeChange: function(){ {$jsSoundFX} },\r\r\n                    directionNav:{$directionNav},\r\r\n                    directionNavHide:{$directionNavHide},\r\r\n                    controlNav:{$controlNav},\r\r\n                    controlNavThumbs:{$controlNavThumbs}, \r\r\n                    controlNavThumbsFromRel:false, \r\r\n                    controlNavThumbsSearch: '{$controlNavThumbsSearch}',\r\r\n                    controlNavThumbsReplace: '{$controlNavThumbsReplace}',\r\r\n                    keyboardNav:{$keyboardNav},\r\r\n                    pauseOnHover:{$pauseOnHover}, \r\r\n                    manualAdvance:{$manualAdvance},\r\r\n                    captionOpacity:{$captionOpacity},\r\r\n                    prevText:'{$prevText}',\r\r\n                    nextText:'{$nextText}',\r\r\n                    randomStart:{$randomStart}\r\r\n                    });\r\r\n                });\r\r\n            })(jQuery);\r\r\n        ");
     $wrapper_class = 'theme-' . $params->get('theme', 'default');
     if ($controlNavThumbs) {
         $wrapper_class .= ' controlnav-thumbs';
     }
     $html = "<div class='{$moduleclassSfx} " . "slider-wrapper " . $wrapper_class . "'>\n" . "<div class='ribbon'></div>\n" . "<div class='nivoSlider'>\n";
     if ($subDir) {
         $this->dirs = array();
         modNivoSliderHelper::subdirs($imagesDir);
         $imagesDir = $this->dirs;
     } else {
         $imagesDir = array($imagesDir);
     }
     $images = modNivoSliderHelper::getImages($params, $imagesDir);
     if (!$images) {
         echo JText::_('Images not found');
         return false;
     }
     list($width, $height, $type, $attr) = getimagesize($images[0]);
     $customStyle .= ".{$moduleclassSfx} .nivoSlider {width:" . $width . "px;height:" . $height . "px;}\n" . $customStyle;
     $document->addStyleDeclaration($customStyle);
     if ($target != '_self') {
         $target = " target='{$target}'";
     } else {
         $target = '';
     }
     $i = 0;
     $p[] = '@\\0|\\t|\\x0B| {2}@i';
     $r[] = '';
     $p[] = '@ +\\||\\| +@i';
     $r[] = '|';
     if (isset($imagesAttributes)) {
         $imagesAttributes = htmlspecialchars(preg_replace($p, $r, $imagesAttributes));
         $imagesAttributes = explode("\n", $imagesAttributes);
         $imgAtt = array();
         foreach ($imagesAttributes as $t) {
             $imgAtt[] = explode("|", $t);
         }
     }
     foreach ($images as $image) {
         $nimg = '';
         if (isset($imgAtt[$i][2])) {
             $nimg = "<a href=\"" . $imgAtt[$i][2] . "\"{$target}>";
         }
         $URLimg = str_replace('+', '%20', str_replace("%2F", "/", urlencode(utf8_encode($images[$i]))));
         $nimg .= "<img src='{$URLOriginal}{$URLimg}'";
         if (isset($imgAtt[$i][0])) {
             $nimg .= " alt='" . $imgAtt[$i][0] . "'";
         }
         if (isset($imgAtt[$i][1])) {
             $nimg .= " title='" . $imgAtt[$i][1] . "'";
         }
         $nimg .= " />";
         if (isset($imgAtt[$i][2])) {
             $nimg .= "</a>";
         }
         $html .= $nimg . "\n";
         $i++;
     }
     $html .= '</div></div>';
     if ($display == true) {
         echo $html;
     } else {
         echo '&nbsp;';
     }
 }
Beispiel #2
0
<?php

/**
 * @package     Nivo-Szaki Slider
 * @link        http://szathmari.hu
 * @version     1.0
 * @copyright   Copyright (C) 2011 szathmari.hu
 * @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
 */
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . DS . 'helper.php';
$imagesDir = rtrim($params->get('imagesDir', 'images/banners/'), '/\\');
if ($params->get('subDir', 0)) {
    $folders = array();
    modNivoSliderHelper::getSubdirs($imagesDir, $folders);
    $imagesDir = $folders;
} else {
    $imagesDir = array($imagesDir);
}
$images = modNivoSliderHelper::getImages($params, $imagesDir);
require JModuleHelper::getLayoutPath('mod_nivoslider');