Skip to content

Commit fc9242f

Browse files
bug fix
1 parent c1c8b67 commit fc9242f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

Module/ContentTextParser.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ class ContentTextParser {
1616
* ]
1717
*/
1818
public static $contentLinks = [];
19+
20+
/**
21+
* ./Master/Contents
22+
*/
1923
public static $currentRootDirectory='';
24+
public static $currentDirectory='';
2025
public static $isInitialized = false;
2126

2227
public static function Init() {
@@ -31,7 +36,8 @@ public static function Init() {
3136

3237
public static function Parse($text, $contentPath, &$context) {
3338
if(!static::$isInitialized) static::Init();
34-
static::$currentRootDirectory = substr(GetTopDirectory($contentPath), 1);
39+
static::$currentRootDirectory = ContentsDatabaseManager::GetRootContentsFolder($contentPath);
40+
static::$currentDirectory = dirname($contentPath);
3541
return OutlineText\Parser::Parse($text, $context);
3642
}
3743

@@ -42,7 +48,17 @@ public static function CreateContext($contentPath) {
4248
}
4349

4450
public static function ParseContentLink($matches, $context) {
45-
$contentPath = URI2Path(static::$currentRootDirectory . '/' . $matches[1][0]);
51+
$path = $matches[1][0];
52+
$contentPath = '';
53+
if(strpos($path, '/') === 0){
54+
// To navigate from the root directory
55+
$contentPath = static::$currentRootDirectory . $path;
56+
}
57+
else {
58+
// To navigate from the current directory
59+
$contentPath = static::$currentDirectory . '/' . $path;
60+
}
61+
Debug::Log($contentPath);
4662
$content = new Content();
4763
if(!$content->SetContent($contentPath)) {
4864
// if not exists, return the text that matched the full pattern.
@@ -54,9 +70,9 @@ public static function ParseContentLink($matches, $context) {
5470
$title = '';
5571
$parent = $content->Parent();
5672
if($parent !== false) {
57-
$title .= $parent->title . '-';
73+
$title .= NotBlankText([$parent->title, basename($parent->path)]) . '-';
5874
}
59-
$title .= $content->title;
75+
$title .= NotBlankText([$content->title, basename($content->path)]);
6076
$href = CreateContentHREF($content->path);
6177
return '<a href="' . $href .'">' . $title . '</a>';
6278
}

Module/ContentsViewerUtils.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ function GetDecodedText($content) {
304304
$text['body'] = ContentTextParser::Parse($content->body, $content->path, $context);
305305

306306
$cache->data['contentLinks'] = ContentTextParser::$contentLinks;
307-
Debug::Log(ContentTextParser::$contentLinks);
308307
$cache->data['text'] = $text;
309308

310309
// 読み込み時の時間を使う

0 commit comments

Comments
 (0)