Файл: gal/core/functions.php
Строк: 32
<?php
/*
+----------------------------+
| Автор: acorn |
| http://profiwm.com/us12097 |
+----------------------------+
*/
final class acorn
{
public static $css = 'css/';
public static $js = 'js/';
public static $img = 'img/';
public static function cssJs($cssJs = array())
{
$ret = array();
foreach ($cssJs as $value) {
switch (pathinfo($value, PATHINFO_EXTENSION)) {
case 'css':
$ret[] = '<link rel="stylesheet" href="' . self::$css . $value . '">';
break;
case 'js':
$ret[] = '<script src="' . self::$js . $value . '"></script>';
break;
}
}
return implode(PHP_EOL, $ret);
}
public static function gallery($random = false)
{
$glob = glob(self::$img . '*.{png,jpg,jpeg,gif}', GLOB_BRACE);
if (empty($glob)) {
return 'Галлерея пока пуста ' . self::img(array('src' => 'core/lis.png', 'alt' => 'печалька')) . ' Загрузите ваши изабражения в папку ' . self::$img;
}
$ret = array();
if ($random) {
shuffle($glob);
}
foreach ($glob as $img) {
$ret['a'][] = self::href(array('href' => '#' . pathinfo($img, PATHINFO_FILENAME), 'title' => 'Увеличить ' . pathinfo($img,
PATHINFO_BASENAME)), self::img(array('src' => $img, 'alt' => pathinfo($img, PATHINFO_BASENAME))));
$ret['b'][] = self::href(array('href' => '#close', 'class' => 'lightbox', 'title' => 'Закрыть ' . pathinfo($img,
PATHINFO_BASENAME), 'id' => pathinfo($img, PATHINFO_FILENAME)),
self::img(array('src' => $img, 'alt' => pathinfo($img, PATHINFO_BASENAME))));
}
return '<div class="thumb">' . implode(PHP_EOL, $ret['a']) . '</div>' . PHP_EOL . implode(PHP_EOL, $ret['b']);
}
public static function href($tags, $title)
{
return '<a ' . self::tags($tags) . '>' . $title . '</a>';
}
public static function img($tags)
{
return '<img ' . self::tags($tags) . '>';
}
private static function tags($tags)
{
$ret = array();
foreach ($tags as $key => $value) {
$ret[] = $key . '="' . $value . '"';
}
return implode(' ', $ret);
}
}