Skip to content

Commit 91cfd02

Browse files
committed
Fix broken legal page in dev environment
1 parent 6b23d3e commit 91cfd02

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/controllers/Legal.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,26 @@
1313

1414
class Legal extends Controller {
1515

16+
const LICENSE_FILE = '../LICENSE.txt';
17+
1618
public function &run( Router &$router, View &$view, array &$args ) {
1719

1820
$model = new LegalModel();
19-
$model->license = file_get_contents( '../LICENSE.txt' );
21+
$model->license = file_get_contents(self::LICENSE_FILE);
2022
$model->license_version = VersionInfo::$version->bnetdocs[3];
21-
$model->license_version = explode( ' ', $model->license_version );
2223

23-
$model->license_version[1] = new DateTime(
24-
$model->license_version[1], new DateTimeZone( 'Etc/UTC' )
25-
);
24+
if (!is_null($model->license_version)) {
25+
$model->license_version = explode( ' ', $model->license_version );
26+
$model->license_version[1] = new DateTime(
27+
$model->license_version[1], new DateTimeZone( 'Etc/UTC' )
28+
);
29+
} else {
30+
$model->license_version = array();
31+
$model->license_version[0] = null;
32+
$model->license_version[1] = new DateTime(
33+
'@' . filemtime(self::LICENSE_FILE), new DateTimeZone( 'Etc/Utc' )
34+
);
35+
}
2636

2737
$view->render( $model );
2838

src/templates/Legal.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ and/or other countries.
8383
?></code></pre></p>
8484
</section>
8585
<footer>
86-
<time datetime="<?php echo $this->getContext()->license_version[1]->format('c'); ?>"><?php echo $this->getContext()->license_version[1]->format("l, F j, Y"); ?></time> (<a href="https://github.com/BNETDocs/bnetdocs-web/commit/<?php echo $this->getContext()->license_version[0]; ?>">version</a>)
86+
<time datetime="<?php echo $this->getContext()->license_version[1]->format('c'); ?>"><?php echo $this->getContext()->license_version[1]->format("l, F j, Y"); ?></time><? if ($this->getContext()->license_version[0]) { ?> (<a href="https://github.com/BNETDocs/bnetdocs-web/commit/<?php echo $this->getContext()->license_version[0]; ?>">version</a>)<? } ?>
8787
</footer>
8888
</article>
8989
<?php require("./footer.inc.phtml"); ?>

0 commit comments

Comments
 (0)