/** * Sestavit kod obrazku v galerii * @param array $img pole s daty obrazku * @param string|null $lightboxid sid lightboxu nebo null (= nepouzivat) * @param int|null $width pozadovana sirka nahledu * @param int|null $height pozadovana vyska nahledu * @return string */ function _galleryImage($img, $lightboxid, $width, $height) { $path = (!_isAbsolutePath($img['full']) ? _indexroot : '') . $img['full']; $content = "<a href='" . $path . "' target='_blank'" . (isset($lightboxid) ? " class='lightbox' data-fancybox-group='lb_" . $lightboxid . "'" : '') . ($img['title'] != "" ? " title='" . $img['title'] . "'" : '') . ">"; if ($img['prev'] != "") { $content .= "<img src='" . (!_isAbsolutePath($img['prev']) ? _indexroot : '') . $img['prev'] . "' alt='" . ($img['title'] != "" ? $img['title'] : _htmlStr(basename($img['full']))) . "' />"; } else { $content .= "<img src='" . _pictureThumb($path, array('x' => $width, 'y' => $height)) . "' alt='" . ($img['title'] != "" ? $img['title'] : _htmlStr(basename($img['full']))) . "' />"; } $content .= "</a>\n"; return $content; }
function _HCM_img($cesta = "", $vyska_nahledu = null, $titulek = null, $lightbox = null) { if (isset($vyska_nahledu) and $vyska_nahledu > 0) { $vyska_nahledu = intval($vyska_nahledu); } else { $vyska_nahledu = 96; } if (isset($titulek) and $titulek != "") { $titulek = _htmlStr($titulek); } if (!isset($lightbox)) { $lightbox = SL::$hcmUid; } $thumb = _pictureThumb($cesta, array('x' => null, 'y' => $vyska_nahledu)); return "<a href='" . _htmlStr($cesta) . "' target='_blank' class='lightbox' data-fancybox-group='lb_hcm" . $lightbox . "'" . ($titulek != "" ? ' title=\'' . $titulek . '\'' : '') . "><img src='" . $thumb . "' alt='" . ($titulek != "" ? $titulek : 'img') . "' /></a>\n"; }
function _HCM_gallery($cesta = "", $rozmery = null, $strankovani = null, $lightbox = 1) { // priprava $result = ""; $cesta = _indexroot . $cesta; $cesta_noroot = $cesta; if (mb_substr($cesta, -1, 1) != "/") { $cesta .= "/"; } if (mb_substr($cesta_noroot, -1, 1) != "/") { $cesta_noroot .= "/"; } if (isset($strankovani) and $strankovani > 0) { $strankovat = true; $strankovani = intval($strankovani); if ($strankovani <= 0) { $strankovani = 1; } } else { $strankovat = false; } $lightbox = _boolean($lightbox); if (isset($rozmery)) { $rozmery = explode('/', $rozmery); if (sizeof($rozmery) === 2) { // sirka i vyska $x = intval($rozmery[0]); $y = intval($rozmery[1]); } else { // pouze vyska $x = null; $y = intval($rozmery[0]); } } else { // neuvedeno $x = null; $y = 128; } if (@file_exists($cesta) and @is_dir($cesta)) { $handle = @opendir($cesta); // nacteni polozek $items = array(); while (false !== ($item = @readdir($handle))) { $ext = pathinfo($item); if (isset($ext['extension'])) { $ext = mb_strtolower($ext['extension']); } else { $ext = ""; } if (@is_dir($item) or $item == "." or $item == ".." or !in_array($ext, SL::$imageExt)) { continue; } $items[] = $item; } @closedir($handle); natsort($items); // priprava strankovani if ($strankovat) { $count = count($items); $paging = _resultPaging(_indexOutput_url, $strankovani, $count, "", "#hcm_gal" . SL::$hcmUid, "hcm_gal" . SL::$hcmUid . "p"); } // vypis $result = "<div class='anchor'><a name='hcm_gal" . SL::$hcmUid . "'></a></div>\n<div class='gallery'>\n"; $counter = 0; foreach ($items as $item) { if ($strankovat and $counter > $paging[6]) { break; } if (!$strankovat or $strankovat and _resultPagingIsItemInRange($paging, $counter)) { $thumb = _pictureThumb($cesta_noroot . $item, array('x' => $x, 'y' => $y)); $result .= "<a href='" . $cesta . _htmlStr($item) . "' target='_blank'" . ($lightbox ? " class='lightbox' data-fancybox-group='lb_hcm" . SL::$hcmUid . "'" : '') . "><img src='" . $thumb . "' alt='" . $item . "' /></a>\n"; } $counter++; } $result .= "</div>\n"; if ($strankovat) { $result .= $paging[0]; } } return $result; }
function _HCM_randomfile($cesta = "", $typ = 1, $pocet = 1, $vyska_nahledu = null) { $result = ""; $cesta = _indexroot . $cesta; $cesta_noroot = $cesta; if (mb_substr($cesta, -1, 1) != "/") { $cesta .= "/"; } if (mb_substr($cesta_noroot, -1, 1) != "/") { $cesta_noroot .= "/"; } $pocet = intval($pocet); if (@file_exists($cesta) and @is_dir($cesta)) { $handle = @opendir($cesta); switch ($typ) { case 2: $allowed_extensions = SL::$imageExt; if (isset($vyska_nahledu)) { $vyska_nahledu = intval($vyska_nahledu); } else { $vyska_nahledu = 96; } break; default: $allowed_extensions = array("txt", "htm", "html"); break; } $items = array(); while (false !== ($item = @readdir($handle))) { $ext = pathinfo($item); if (isset($ext['extension'])) { $ext = mb_strtolower($ext['extension']); } else { $ext = ""; } if (@is_dir($cesta . $item) or $item == "." or $item == ".." or !in_array($ext, $allowed_extensions)) { continue; } $items[] = $item; } if (count($items) != 0) { if ($pocet > count($items)) { $pocet = count($items); } $randitems = array_rand($items, $pocet); if (!is_array($randitems)) { $randitems = array($randitems); } foreach ($randitems as $item) { $item = $items[$item]; switch ($typ) { case 2: $thumb = _pictureThumb($cesta_noroot . $item, array('x' => null, 'y' => $vyska_nahledu)); $result .= "<a href='" . $cesta . _htmlStr($item) . "' target='_blank' class='lightbox' data-fancybox-group='lb_hcm" . SL::$hcmUid . "'><img src='" . $thumb . "' alt='" . $item . "' /></a>\n"; break; default: $result .= @file_get_contents(_indexroot . $cesta . $item); break; } } } @closedir($handle); } return $result; }