public
getJsSlideshow
(mixed $catid, mixed $id, mixed $slideshow = 0, mixed $catidSlug = '', mixed $idSlug = '')
/*
* Get Slideshow - 1. data for javascript, 2. data for displaying buttons
*/
public function getJsSlideshow($catid, $id, $slideshow = 0, $catidSlug = '', $idSlug = '')
{
jimport('joomla.filesystem.file');
phocagalleryimport('phocagallery.file.filethumbnail');
$app = Factory::getApplication();
$db = Factory::getDBO();
$params = $app->getParams();
//$image_ordering = $params->get( 'image_ordering', 1 );
//$imageOrdering = PhocaGalleryOrdering::getOrderingString($image_ordering);
$detailWindow = $params->get('detail_window', 0);
if ($detailWindow == 7) {
$tCom = '';
} else {
$tCom = '&tmpl=component';
}
$i = explode(':', $idSlug);
$id = $i[0];
$alias = $i[1];
$j = explode(':', $catidSlug);
$catid = $j[0];
$catalias = $j[1];
$href = PhocaGalleryRoute::getImageRoute($id, $catid, $alias, $catalias) . $tCom;
// 1. GET DATA FOR JAVASCRIPT
$jsSlideshowData['files'] = '';
//Get filename of all photos
$query = 'SELECT a.id, a.filename, a.extl, a.description' . ' FROM #__phocagallery AS a' . ' LEFT JOIN #__phocagallery_img_votes_statistics AS r ON r.imgid = a.id' . ' WHERE a.catid=' . (int) $catid . ' AND a.published = 1 AND a.approved = 1' . $this->_imgordering['output'];
$db->setQuery($query);
$filenameAll = $db->loadObjectList();
$countImg = 0;
$endComma = ',';
if (!empty($filenameAll)) {
$countFilename = count($filenameAll);
foreach ($filenameAll as $key => $value) {
$countImg++;
if ($countImg == $countFilename) {
$endComma = '';
}
$filterTags = array();
$filterAttrs = array();
$filter = new InputFilter($filterTags, $filterAttrs, 1, 1, 1);
$description = $filter->clean(PhocaGalleryText::strTrimAll($value->description), 'html');
$description = addslashes($value->description);
$description = trim($description);
$description = str_replace("\n", '', $description);
$description = str_replace("\r", '', $description);
if (isset($value->extl) && $value->extl != '') {
$jsSlideshowData['files'] .= '["' . $value->extl . '", "", "", "' . $description . '"]' . $endComma . "\n";
} else {
$fileThumbnail = PhocaGalleryFileThumbnail::getThumbnailName($value->filename, 'large');
$imgLink = Uri::base(true) . '/' . $fileThumbnail->rel;
if (File::exists($fileThumbnail->abs)) {
$jsSlideshowData['files'] .= '["' . $imgLink . '", "", "", "' . $description . '"]' . $endComma . "\n";
} else {
$fileThumbnail = Uri::base(true) . '/' . "media/com_phocagallery/images/phoca_thumb_l_no_image.png";
$jsSlideshowData['files'] .= '["' . $fileThumbnail . '", "", "", ""]' . $endComma . "\n";
}
}
}
}
// 2. GET DATA FOR DISPLAYING SLIDESHOW BUTTONS
//We can display slideshow option if there is more than one foto
//But in database there can be more photos - more rows but if file is in db but it doesn't exist, we don't count it
//$countImg = SQLQuery::selectOne($mdb2, "SELECT COUNT(*) FROM $db_gallery WHERE siteid=$id");
if ($countImg > 1) {
//Data from GET['COM_PHOCAGALLERY_SLIDESHOW']
if ($slideshow == 1) {
$jsSlideshowData['icons'] = '<div class="pg-imgbgd">' . '<a href="' . Route::_($href . '&phocaslideshow=0') . '" title="' . Text::_('COM_PHOCAGALLERY_STOP_SLIDESHOW') . '" >' . PhocaGalleryRenderFront::renderIcon('stop', 'media/com_phocagallery/images/icon-stop.png', Text::_('COM_PHOCAGALLERY_STOP_SLIDESHOW')) . '</a></div>' . '</td><td align="center">' . PhocaGalleryRenderFront::renderIcon('play', 'media/com_phocagallery/images/icon-play-grey.png', Text::_('COM_PHOCAGALLERY_STOP_SLIDESHOW'), 'ph-icon-disabled');
} else {
$jsSlideshowData['icons'] = PhocaGalleryRenderFront::renderIcon('stop', 'media/com_phocagallery/images/icon-stop-grey.png', Text::_('COM_PHOCAGALLERY_STOP_SLIDESHOW'), 'ph-icon-disabled') . '</td><td align="center">' . '<div class="pg-imgbgd">' . '<a href="' . Route::_($href . '&phocaslideshow=1') . '" title="' . Text::_('COM_PHOCAGALLERY_START_SLIDESHOW') . '">' . PhocaGalleryRenderFront::renderIcon('play', 'media/com_phocagallery/images/icon-play.png', Text::_('COM_PHOCAGALLERY_START_SLIDESHOW')) . '</a></div>';
}
} else {
$jsSlideshowData['icons'] = '';
}
return $jsSlideshowData;
//files (javascript) and icons (buttons)
}