";
// GETCATGEGORIES
$ch = curl_init($siteUrl . "ws.php?format=json&method=pwg.categories.getList&cat_id=" . $currentCat);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$getCat = curl_exec($ch);
$catsJson = json_decode($getCat, true);
if(!empty($catsJson['result']['categories']['1']['id'])) {
$categories = '
' . $catsJson['result']['categories']['0']['name'] . '
';
}
foreach ($catsJson['result']['categories'] as $item) {
$id = $item['id'];
$catName = $item['name'];
$catComment = $item['comment'];
$catImageCount = $item['total_nb_images'];
$catSubCount = $item['nb_categories'];
$catImage = $item['tn_url'];
// HIDE IMAGE IF EMPTY
if(!empty($catImage)) {
$catImage = '';
} else {
}
// HIDE COMMENT IF EMPTY
if($item['comment'] == '') {
$comment = '';
} else {
$comment = '
' . $item['comment'];
}
$catCount = '';
// SHOW IMAGE COUNT
if($catImageCount == 0 && $catSubCount == 0) {
} elseif($catImageCount > 1) {
$catCount .= $catImageCount . ' Fotos';
} else {
$catCount .= $catImageCount . ' Foto';
}
// SHOW SUB CATEGORIES COUNT
if($catSubCount == 0) {
} elseif($catSubCount > 1) {
$catCount .= ' in ';
$catCount .= $catSubCount . ' Unteralben';
} else {
$catCount .= ' in ';
$catCount .= $catSubCount . ' Unteralbum';
}
// HIDE CURRENT CATEGORY
if($id == $currentCat || empty($catImage)) {
$thisTotalImages = $catImageCount;
$thisCatName = $catName;
} else {
$categories .= $this->cObj->typolink($catImage . '' . '
' . $catName . '
' . $catCount . '',
array( // parameter
'parameter' => 52,
'additionalParams' => '&piwigoCat=' . $id,
'useCacheHash' => 0
)
);
}
}
// GET IMAGES
$ch = curl_init($siteUrl . "ws.php?format=json&method=pwg.categories.getImages&cat_id=" . $currentCat .'&per_page=' . $browserImageCount . '&page=' . $imagePage);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$getImages = curl_exec($ch);
$imagesJson = json_decode($getImages, true);
if($currentCat == '0') {
} else {
if($imagesJson['result']['images']['count'] == 0) {
} else {
$images = '' . $thisCatName . '
';
foreach ($imagesJson['result']['images']['_content'] as $item) {
$image = $item['derivatives']['square']['url'];
$width = $item['derivatives']['square']['width'];
$height = $item['derivatives']['square']['height'];
$imageHd = $item['derivatives']['xlarge']['url'];
$imageHdWidth = $item['derivatives']['xlarge']['width'] + 20;
$imageHdHeight = $item['derivatives']['xlarge']['height'] + 20;
$imageCat = $item['categories']['id'];
if($item['comment'] == null) {
$comment = '';
} else {
$comment = '
' . $item['comment'];
}
$images .= '';
$images .= '
';
$images .= '
' . $item['name'] . '
';
$images .= '
';
}
$pagesTotal = ceil($thisTotalImages / $browserImageCount);
$backId = $imagePage - 1;
if($imagePage == 0) {
$back = '';
} else {
$back .= $this->cObj->typolink('BACK',
array( // parameter
'parameter' => 52,
'additionalParams' => '&piwigoCat=' . $id . '&imagePage=' . $backId,
'useCacheHash' => 0
)
);
}
$nextId = $imagePage + 1;
if($pagesTotal == $nextId) {
$next = '';
} else {
$next .= $this->cObj->typolink('NEXT',
array( // parameter
'parameter' => 52,
'additionalParams' => '&piwigoCat=' . $id . '&imagePage=' . $nextId,
'useCacheHash' => 0
)
);
}
for ($i=0; $i<(int)$pagesTotal; $i++) {
$pageNumber = $i+1;
$currentPage = $imagePage + 1;
if($pageNumber == $currentPage) {
$imagePages .= $pageNumber;
} else {
$imagePages .= $this->cObj->typolink($pageNumber,
array( // parameter
'parameter' => 52,
'additionalParams' => '&piwigoCat=' . $id . '&imagePage=' . $i,
'useCacheHash' => 0
)
);
}
}
$imageBrowser = '' . $back . $imagePages . $next . '
';
}
}
$content .= $link . '' . $images . $imageBrowser . '
' . '' . $categories . $catBrowser . '
';
return $content;
}
}
?>