Skip to content

Commit c8da3de

Browse files
Merge pull request #147 from ContentsViewer/pre
layer名を言語コードに限定
2 parents 31f5199 + 4821ec9 commit c8da3de

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Module/ContentsDatabaseManager.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ public static function GetRelatedLayers($contentPath){
9696
$files = glob($realDirname . '/' . $pattern);
9797
foreach($files as $file){
9898
$info = static::GetContentPathInfo($file);
99-
if($concatExtentions === implode('.', $info['extentions'])){
99+
if(
100+
$info['filename'] === $pathInfo['filename'] &&
101+
$concatExtentions === implode('.', $info['extentions'])
102+
){
100103
$layers[] = $info['layername'];
101104
}
102105
}
@@ -139,7 +142,22 @@ public static function GetContentPathInfo($contentPath){
139142

140143
if(($pos = strrpos($filename, '_')) != false){
141144
$layername = substr($filename, $pos + 1);
142-
$filename = substr($filename, 0, $pos);
145+
// {言語コード(ISO 639-1)}
146+
// (
147+
// (-{国名コード(ISO 3166-1 Alpha 2)}) |
148+
// (-{文字体系(ISO 15924)}(-{国名コード(ISO 3166-1 Alpha 2)})?)
149+
// )?
150+
//
151+
// 言語コード(ISO 639-1): [a-z][a-z]
152+
// 国名コード(ISO 3166-1 Alpha 2): [A-Z][A-Z]
153+
// 文字体系(ISO 15924): [A-Z][a-z][a-z][a-z]
154+
//
155+
if(preg_match('/^[a-z][a-z]((-[A-Z][A-Z])|(-[A-Z][a-z][a-z][a-z](-[A-Z][A-Z])?))?$/', $layername) === 1){
156+
$filename = substr($filename, 0, $pos);
157+
}
158+
else{
159+
$layername = false;
160+
}
143161
}
144162

145163
$info['filename'] = $filename;

0 commit comments

Comments
 (0)