|
6 | 6 | $PageVersion = new PageVersion(); |
7 | 7 |
|
8 | 8 | class PageVersion { |
| 9 | + // TODO: - avoid public fields and use getters/setters instead |
| 10 | + |
9 | 11 | public $active; |
10 | 12 | public $versions, $basePath, $versionedPath, $subPath, $path; |
11 | 13 | public $currentVersion; |
@@ -71,29 +73,39 @@ static function WriteBanner() { |
71 | 73 | global $PageVersion; |
72 | 74 | if(!$PageVersion->active) return; |
73 | 75 |
|
74 | | - if($PageVersion->isCurrentPageCurrent() || !$PageVersion->currentFileExists) { |
| 76 | + if($PageVersion->isCurrentPageCurrent()) { |
75 | 77 | // Don't show the banner if we are on the current version |
76 | 78 | return; |
77 | 79 | } |
78 | 80 |
|
79 | | - if($PageVersion->isCurrentPageOlder()) { |
80 | | - $message = 'You are viewing an old version of this documentation'; |
81 | | - } else { |
82 | | - $message = 'You are viewing an incomplete pre-release version of this documentation'; |
83 | | - } |
84 | | - |
85 | 81 | $alertIcon = |
86 | 82 | '<svg class="octicon octicon-alert mr-2" viewBox="0 0 16 16" version="1.1" width="22" height="22" '. |
87 | 83 | 'style="vertical-align: bottom; padding-right: 4px" aria-hidden="true">'. |
88 | 84 | '<path fill="orange" d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 '. |
89 | 85 | '1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 '. |
90 | 86 | '0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 '. |
91 | 87 | '0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>'; |
92 | | - $target = PageVersion::GetVersionedFilePath($PageVersion->basePath, $PageVersion->file, $PageVersion->currentVersion, $PageVersion->currentVersion); |
| 88 | + |
| 89 | + if(!$PageVersion->currentFileExists) { |
| 90 | + $message = "You are viewing documentation of version {$PageVersion->versionedPath}, which is not included in the latest version"; |
| 91 | + } else if($PageVersion->isCurrentPageOlder()) { |
| 92 | + $message = 'You are viewing an old version of this documentation'; |
| 93 | + } else { |
| 94 | + $message = 'You are viewing an incomplete pre-release version of this documentation'; |
| 95 | + } |
| 96 | + |
| 97 | + if(!$PageVersion->currentFileExists) { |
| 98 | + # redirect to the base folder for the current version, as we don't have a mapping for this page |
| 99 | + $target = "{$PageVersion->basePath}/current-version/"; |
| 100 | + $actionText = "to open the index page for version {$PageVersion->currentVersion}."; |
| 101 | + } else { |
| 102 | + $target = PageVersion::GetVersionedFilePath($PageVersion->basePath, $PageVersion->file, $PageVersion->currentVersion, $PageVersion->currentVersion); |
| 103 | + $actionText = "to open the current version, {$PageVersion->currentVersion}."; |
| 104 | + } |
93 | 105 | $html = |
94 | 106 | "<div id='version-banner'>$alertIcon $message. ". |
95 | | - "<a href='{$target}'>Click here</a>". |
96 | | - " to open the current version, {$PageVersion->currentVersion}.</div>"; |
| 107 | + "<a href='{$target}'>Click here</a> $actionText". |
| 108 | + "</div>"; |
97 | 109 | echo $html; |
98 | 110 | } |
99 | 111 |
|
|
0 commit comments