|
|
|
@ -75,11 +75,26 @@ Class DirScanner {
@@ -75,11 +75,26 @@ Class DirScanner {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//解析描述文件内容 |
|
|
|
|
private function parseDescriptionFiles($realpath) { |
|
|
|
|
//snapshot相对路径完善,支持secure_link |
|
|
|
|
private function parseDescriptionFiles($realpath, $dirLevel) { |
|
|
|
|
$pathinfo = pathinfo($realpath); |
|
|
|
|
$field = preg_replace('/^.+_/', '', $pathinfo['filename']); |
|
|
|
|
$content = file_get_contents($realpath); |
|
|
|
|
$data = []; |
|
|
|
|
if (in_array($field, ['title', 'snapshot'])) { |
|
|
|
|
$content = preg_replace('/\s/', '', $content); |
|
|
|
|
if ($field == 'snapshot') { |
|
|
|
|
$img_realpath = str_replace("{$pathinfo['filename']}.{$pathinfo['extension']}", $content, $realpath); |
|
|
|
|
echo "img_realpath: ".$img_realpath."\n"; |
|
|
|
|
$id = $this->getId($img_realpath); |
|
|
|
|
$fp = fopen($img_realpath, 'r'); |
|
|
|
|
$fstat = fstat($fp); |
|
|
|
|
fclose($fp); |
|
|
|
|
$img_pathinfo = pathinfo($img_realpath); |
|
|
|
|
$extension = strtolower($img_pathinfo['extension']); |
|
|
|
|
$content = $this->getFilePath( $id, $this->getDirectoryName($img_pathinfo['dirname'], $dirLevel), $img_pathinfo['filename'], $extension, $fstat['mtime'] ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$data[$field] = $content; |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
@ -206,9 +221,9 @@ Class DirScanner {
@@ -206,9 +221,9 @@ Class DirScanner {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//合并描述文件内容到md文件或者目录数据 |
|
|
|
|
private function mergeDescriptionData($realpath) { |
|
|
|
|
private function mergeDescriptionData($realpath, $dirLevel) { |
|
|
|
|
$data = []; |
|
|
|
|
$ext = $this->parseDescriptionFiles($realpath); |
|
|
|
|
$ext = $this->parseDescriptionFiles($realpath, $dirLevel); |
|
|
|
|
|
|
|
|
|
//try to find the md file |
|
|
|
|
$targetFile = preg_replace('/_?[a-z0-9]+\.txt$/iU', '.md', $realpath); |
|
|
|
@ -481,7 +496,7 @@ Class DirScanner {
@@ -481,7 +496,7 @@ Class DirScanner {
|
|
|
|
|
$branch = $this->getFileData($realpath, $this->scanningDirLevel); |
|
|
|
|
}else { |
|
|
|
|
//把描述文件内容合并到被描述的目录或md文件数据中 |
|
|
|
|
$branch = $this->mergeDescriptionData($realpath); |
|
|
|
|
$branch = $this->mergeDescriptionData($realpath, $this->scanningDirLevel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -521,10 +536,10 @@ Class DirScanner {
@@ -521,10 +536,10 @@ Class DirScanner {
|
|
|
|
|
'path' => $item['path'], |
|
|
|
|
]; |
|
|
|
|
if (!empty($item['snapshot'])) { |
|
|
|
|
$dir['snapshot'] = preg_replace('/\s/', '', $item['snapshot']); |
|
|
|
|
$dir['snapshot'] = $item['snapshot']; |
|
|
|
|
} |
|
|
|
|
if (!empty($item['title'])) { |
|
|
|
|
$dir['title'] = preg_replace('/\s/', '', $item['title']); |
|
|
|
|
$dir['title'] = $item['title']; |
|
|
|
|
} |
|
|
|
|
if (!empty($item['description'])) { |
|
|
|
|
$dir['description'] = $item['description']; |
|
|
|
|