$ans['order'] = $order; $list = Access::cache(__FILE__, function ($dir, $order) { $list = array(); array_map(function ($file) use(&$list, $dir) { if ($file[0] == '.') { return; } $file = Path::toutf($file); if (!Path::theme($dir . $file)) { return; } $fd = Load::nameInfo($file); if (!in_array($fd['ext'], array('jpg', 'png'))) { return; } $slide = $fd; $slide['title'] = $fd['name']; $src = Rubrics::find($dir, $fd['name'], 'articles'); if ($src) { $slide['title'] = Rubrics::article($src); } $list[] = $slide; }, scandir(Path::theme($dir))); Load::sort($list, $order); //$list = array_reverse($list); return $list; }, array($dir, $order)); $list = array_slice($list, $start, $count); $ans['dir'] = $dir; $ans['list'] = $list; return Ans::ret($ans);
public static function info($src) { if (!Path::theme($src)) { return array(); } $rr = Load::srcInfo($src); $ext = $rr['ext']; $size = filesize(Path::theme($src)); if (in_array($ext, array('mht', 'tpl', 'html', 'txt', 'php'))) { $rr = Mht::preview($src); } elseif (in_array($ext, array('docx'))) { $rr = Docx::preview($src); } $rr['size'] = round($size / 1000000, 2); //Mb if (!empty($rr['links'])) { $links = $rr['links']; unset($rr['links']); foreach ($links as $v) { $r = preg_match('/http.*youtube\\.com.*watch.*=([\\w\\-]+).*/', $v['href'], $match); $r2 = preg_match('/http.{0,1}:\\/\\/youtu\\.be\\/([\\w\\-]+)/', $v['href'], $match); if ($r) { if (empty($rr['video'])) { $rr['video'] = array(); } $v['id'] = $match[1]; $rr['video'][] = $v; } elseif ($r2) { if (empty($rr['video'])) { $rr['video'] = array(); } $v['id'] = $match[1]; $rr['video'][] = $v; } else { if (empty($rr['links'])) { $rr['links'] = array(); } $rr['links'][] = $v; } } } if (!empty($rr['name'])) { $dir = Path::theme($rr['folder'] . $rr['name'] . '/'); if ($dir) { $list = array(); array_map(function ($file) use(&$list, $src) { if ($file[0] == '.') { return; } //if (!is_file($dir.$file)) return; $fd = Load::nameinfo($file); if (!in_array($fd['ext'], ['jpeg', 'jpg', 'png'])) { return; } $list[] = Path::toutf($fd); }, scandir($dir)); Load::sort($list, 'ascending'); foreach ($list as $k => $fd) { $list[$k] = Path::toutf($fd['file']); } $rr['gallerydir'] = $rr['folder'] . $rr['name'] . '/'; $rr['gallery'] = $list; } } return $rr; }
return; } if ($file[0] == '~') { return; } //Скрытый файл Word if (!is_file(Path::theme($dir) . $file)) { return; } $fd = Load::nameinfo($file); if (!in_array($fd['ext'], array('docx', 'html', 'tpl'))) { return; } $list[] = Rubrics::info(Path::toutf($dir . $file)); }, scandir(Path::theme($dir))); Load::sort($list); return $list; }, array($dir)); $list = array_slice($list, $start, $count); $ans['list'] = $list; } else { if ($type == 'page') { if ($type == 'page') { $id = Ans::GET('id'); } if (!$id) { return Ans::err($ans, 'Для type=page необходимо указать id страницы'); } $src = Rubrics::find($dir, $id); $ans['info'] = Rubrics::info($src); $ans['text'] = Rubrics::article($src);