|
47 | 47 | (($parent === false || $parent->IsRoot()) ? '' : ' ' . NotBlankText([$parent->title, basename($parent->path)]) ); |
48 | 48 |
|
49 | 49 | $titleSuggestions = SearchEngine\Searcher::Search($titleQuery); |
50 | | - |
| 50 | +// Debug::Log($titleSuggestions); |
51 | 51 | // score 0.5 未満 は除外 |
52 | 52 | foreach($titleSuggestions as $i => $suggestion){ |
53 | 53 | if($suggestion['score'] < 0.5){ |
|
83 | 83 | // } |
84 | 84 | // $uniqueKeys[$suggestion['id']] = true; |
85 | 85 | // } |
86 | | - |
87 | | -$titleSuggestions = SelectDifferentDirectoryContents($titleSuggestions, $currentContent->path); |
88 | | -$tagSuggestions = SelectDifferentDirectoryContents($tagSuggestions, $currentContent->path); |
| 86 | +$childPathList = []; |
| 87 | +if($parent !== false){ |
| 88 | + $childCount = $parent->ChildCount(); |
| 89 | + for($i = 0; $i < $childCount; $i++){ |
| 90 | + if(($child = $parent->Child($i)) !== false){ |
| 91 | + $childPathList[] = $child->path; |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | +// Debug::Log($childPathList); |
| 96 | +$titleSuggestions = SelectDifferentDirectoryContents($titleSuggestions, $currentContent->path, $childPathList); |
| 97 | +$tagSuggestions = SelectDifferentDirectoryContents($tagSuggestions, $currentContent->path, $childPathList); |
89 | 98 |
|
90 | 99 | // End 関連コンテンツの検索 ================================================= |
91 | 100 |
|
@@ -198,11 +207,17 @@ function CountSteps($pathFrom, $pathTo){ |
198 | 207 | return $steps; |
199 | 208 | } |
200 | 209 |
|
201 | | -function SelectDifferentDirectoryContents($suggestions, $currentContentPath){ |
| 210 | +function SelectDifferentDirectoryContents($suggestions, $currentContentPath, $childPathList){ |
202 | 211 | foreach($suggestions as $i => $suggestion){ |
| 212 | + if(in_array($suggestion['id'], $childPathList)){ |
| 213 | + unset($suggestions[$i]); |
| 214 | + continue; |
| 215 | + } |
| 216 | + |
203 | 217 | $steps = CountSteps($suggestion['id'], $currentContentPath); |
204 | 218 | if($steps !== false && $steps < 4){ |
205 | 219 | unset($suggestions[$i]); |
| 220 | + continue; |
206 | 221 | } |
207 | 222 | } |
208 | 223 | return $suggestions; |
|
0 commit comments