function getSlides($params) { $slides = array(); $pathList = AriImageSliderHelper::getPathList($params->get('path')); if (count($pathList) == 0) { return $slides; } $extraFields = array(); $i18n = (bool) $params->get('i18n', false); $descrFile = trim($params->get('descrFile', '')); $processDescrFile = !empty($descrFile); $processSubDir = (bool) $params->get('subdir'); $subdirLevel = intval($params->get('subdirLevel', 0), 10); if ($subdirLevel < 1) { $subdirLevel = true; } else { --$subdirLevel; } $imgNumber = intval($params->get('imgNumber', 0), 10); $images = array(); $sort = AriImageSliderHelper::getSortExpr($params); $cwd = getcwd(); if ($cwd != JPATH_ROOT) { chdir(JPATH_ROOT); } else { $cwd = null; } foreach ($pathList as $path) { if (empty($path)) { continue; } if (@is_file($path)) { $images[] = $path; $path = dirname($path); } else { $folderImages = AriFolder::files($path, '.(jpg|gif|jpeg|png|bmp|JPG|GIF|JPEG|BMP)$', $processSubDir ? $subdirLevel : false, true, $sort); if (is_array($folderImages) && count($folderImages) > 0) { if ($imgNumber > 0 && count($folderImages) > $imgNumber) { $folderImages = array_slice($folderImages, 0, $imgNumber); } $images = array_merge($images, $folderImages); } } if ($processDescrFile) { $folderExtraFields = AriAppUtils::getExtraFieldsFromINI($path, $descrFile, $processSubDir, true, $i18n); if (is_array($folderExtraFields) && count($folderExtraFields) > 0) { $extraFields = array_merge($extraFields, $folderExtraFields); } } } if (!is_null($cwd)) { chdir($cwd); } $useThumbs = (bool) $params->get('imglist_useThumbs'); $cachePath = $useThumbs ? AriImageSliderHelper::getCachePath() : null; $thumbPath = $params->get('imglist_thumbPath'); $thumbWidth = intval($params->get('imglist_thumbWidth'), 10); $thumbHeight = intval($params->get('imglist_thumbHeight'), 10); $navThumbs = (bool) $params->get('opt_controlNavThumbs'); $navThumbWidth = intval($params->get('imglist_navThumbWidth'), 10); $navThumbHeight = intval($params->get('imglist_navThumbHeight'), 10); $navThumbPath = $params->get('imglist_navThumbPath'); $navCachePath = AriImageSliderHelper::getCachePath(); $defaultDescr = $params->get('defaultDescription'); $defLink = $params->get('defaultLink'); $processDefaultDescr = $defaultDescr && strpos($defaultDescr, '{$') !== false; foreach ($images as $image) { $originalSlide = $slide = array('src' => $image, 'image' => str_replace('\\', '/', $image)); if ($processDescrFile) { if (isset($extraFields[$image])) { $slide = array_merge($extraFields[$image], $slide); } else { $cleanImage = str_replace('/', '\\', $image); if (isset($extraFields[$cleanImage])) { $slide = array_merge($extraFields[$cleanImage], $slide); } } } if (empty($slide['description']) && $defaultDescr) { $slide['description'] = $processDefaultDescr ? str_replace(array('{$fileName}', '{$baseFileName}'), array(basename($image), JFile::stripExt(basename($image))), $defaultDescr) : $defaultDescr; } if ($useThumbs) { $slide = AriImageSliderHelper::generateThumbnail($slide, $thumbWidth, $thumbHeight, $thumbPath, $cachePath, $defLink); } if ($navThumbs) { $navThumb = AriImageSliderHelper::generateThumbnail($originalSlide, $navThumbWidth, $navThumbHeight, $navThumbPath, $navCachePath); $navThumb['alt'] = !empty($slide['alt']) ? $slide['alt'] : ''; $slide['nav'] = $navThumb; } $slides[] = $slide; } return $slides; }
function getSlides($params) { $slides = array(); $pathList = AriImageSliderHelper::getPathList($params->get('path')); //print_r($pathList);// nam if (count($pathList) == 0) { return $slides; } $extraFields = array(); $i18n = (bool) $params->get('i18n', false); $descrFile = trim($params->get('descrFile', '')); $processDescrFile = !empty($descrFile); $processSubDir = (bool) $params->get('subdir'); $imgNumber = intval($params->get('imgNumber', 0), 10); $images = array(); $sort = AriImageSliderHelper::getSortExpr($params); foreach ($pathList as $path) { if (empty($path)) { continue; } if (@is_file($path)) { $images[] = $path; $path = dirname($path); } else { $folderImages = AriFolder::files($path, '.(jpg|gif|jpeg|png|bmp|JPG|GIF|JPEG|BMP)$', $processSubDir, true, $sort); if (is_array($folderImages) && count($folderImages) > 0) { if ($imgNumber > 0 && count($folderImages) > $imgNumber) { $folderImages = array_slice($folderImages, 0, $imgNumber); } $images = array_merge($images, $folderImages); } } if ($processDescrFile) { $folderExtraFields = AriAppUtils::getExtraFieldsFromINI($path, $descrFile, $processSubDir, true, $i18n); if (is_array($folderExtraFields) && count($folderExtraFields) > 0) { $extraFields = array_merge($extraFields, $folderExtraFields); } } } //print_r($images[0]);// nam sua $useThumbs = (bool) $params->get('imglist_useThumbs'); $cachePath = $useThumbs ? AriImageSliderHelper::getCachePath() : null; $thumbPath = $params->get('imglist_thumbPath'); $thumbWidth = intval($params->get('imglist_thumbWidth'), 10); $thumbHeight = intval($params->get('imglist_thumbHeight'), 10); // duoi day la nam viet------------------------------------------------- $titlenam = $params->get('path_title'); $mang1 = explode("\n", $titlenam); $linknam = $params->get('path_link'); $mang2 = explode("\n", $linknam); $i = 0; //------------------------------------------------------- foreach ($images as $image) { $slide = array('src' => $image, 'image' => str_replace('\\', '/', $image), 'description' => $mang1[$i], 'link' => $mang2[$i]); //echo $mang2[$i]."-------------"; $i++; if ($processDescrFile && isset($extraFields[$image])) { $slide = array_merge($extraFields[$image], $slide); } if ($useThumbs) { $slide = AriImageSliderHelper::generateThumbnail($slide, $thumbWidth, $thumbHeight, $thumbPath, $cachePath); } $slides[] = $slide; } return $slides; }