|
|
@ -92,18 +92,21 @@ Class DirScanner { |
|
|
|
|
|
|
|
|
|
|
|
//解析描述文件内容 |
|
|
|
//解析描述文件内容 |
|
|
|
//snapshot相对路径完善,支持secure_link |
|
|
|
//snapshot相对路径完善,支持secure_link |
|
|
|
|
|
|
|
//bug fix: 允许空内容文件,如:刚创建的分类文件 |
|
|
|
private function parseDescriptionFiles($realpath) { |
|
|
|
private function parseDescriptionFiles($realpath) { |
|
|
|
$filename = $this->getFilenameWithoutExtension($realpath); |
|
|
|
$filename = $this->getFilenameWithoutExtension($realpath); |
|
|
|
$pathinfo = pathinfo($realpath); |
|
|
|
$pathinfo = pathinfo($realpath); |
|
|
|
$tmp = explode('_', $filename); |
|
|
|
$tmp = explode('_', $filename); |
|
|
|
$field = array_pop($tmp); |
|
|
|
$field = array_pop($tmp); //['title', 'snapshot'] |
|
|
|
$content = @file_get_contents($realpath); |
|
|
|
$content = @file_get_contents($realpath); |
|
|
|
if (empty($content)) {return [];} |
|
|
|
if (!empty($content)) { |
|
|
|
$content = trim($content); |
|
|
|
$content = trim($content); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data = array(); |
|
|
|
$data = array(); |
|
|
|
if (in_array($field, ['title', 'snapshot'])) { |
|
|
|
|
|
|
|
if ($field == 'snapshot') { |
|
|
|
//如果是快照图片,获取图片相对路径 |
|
|
|
|
|
|
|
if (!empty($content) && $field == 'snapshot') { |
|
|
|
$img_realpath = realpath("{$pathinfo['dirname']}/{$content}"); |
|
|
|
$img_realpath = realpath("{$pathinfo['dirname']}/{$content}"); |
|
|
|
if (file_exists($img_realpath)) { |
|
|
|
if (file_exists($img_realpath)) { |
|
|
|
$id = $this->getId($img_realpath); |
|
|
|
$id = $this->getId($img_realpath); |
|
|
@ -116,7 +119,8 @@ Class DirScanner { |
|
|
|
$content = $this->getFilePath( $id, $this->getRelativeDirname($img_pathinfo['dirname']), $img_filename, $extension, $fstat['mtime'] ); |
|
|
|
$content = $this->getFilePath( $id, $this->getRelativeDirname($img_pathinfo['dirname']), $img_filename, $extension, $fstat['mtime'] ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//返回文件数据 |
|
|
|
$data[$field] = $content; |
|
|
|
$data[$field] = $content; |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|