Skip to content

Commit

Permalink
include changes from opensb 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PF94 committed Oct 7, 2024
1 parent 51e67eb commit 4fabeeb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .idea/OpenSB.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion private/class/Core/Templating.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public function __construct(array $options, Database $database, Authentication $

$showWarningBanner = false;

$versionNumber = new VersionNumber;

$this->twig->addGlobal('is_chaziz_sb', $isChazizSB);
$this->twig->addGlobal('is_fulptube', $isFulpTube);
$this->twig->addGlobal('is_debug', $isDebug);
Expand All @@ -147,7 +149,7 @@ public function __construct(array $options, Database $database, Authentication $
$this->twig->addGlobal('user_is_admin', $auth->isUserAdmin());
$this->twig->addGlobal('user_is_authenticated_admin', $auth->hasUserAuthenticatedAsAnAdmin());
$this->twig->addGlobal('skins', $this->getAllSkinsMetadata());
$this->twig->addGlobal('opensb_version', (new VersionNumber)->getVersionString());
$this->twig->addGlobal('opensb_version', $versionNumber->getVersionNumber());
$this->twig->addGlobal('session', $_SESSION);
$this->twig->addGlobal('website_branding', $branding);
$this->twig->addGlobal('current_theme', $this->theme); // not to be confused with skins
Expand All @@ -157,6 +159,7 @@ public function __construct(array $options, Database $database, Authentication $
$this->twig->addGlobal('current_skin_and_theme', $this->skin . ',' . $this->theme);
// temporary
$this->twig->addGlobal('show_warning_banner', $showWarningBanner);
$this->twig->addGlobal('is_opensb_v2', true);

/*
if ($this->skin == "finalium" && $this->theme == "beta")
Expand Down
28 changes: 19 additions & 9 deletions private/class/Core/VersionNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

class VersionNumber
{
private string $version;
private string $versionNumber;
private string $versionString;

public function __construct() {
$this->makeVersionString();
$this->versionNumber = "2.0-alpha";
$this->versionString = $this->makeVersionString();
}

/**
* Make SquareBracket's version number.
*/
private function makeVersionString(): void
private function makeVersionString(): string
{
if (file_exists(SB_GIT_PATH)) {
$gitHead = file_get_contents(SB_GIT_PATH . '/HEAD');
Expand All @@ -22,11 +24,9 @@ private function makeVersionString(): void

$hash = substr($commit, 0, 7);

$versionNumber = "2.0-alpha";

$this->version = sprintf('%s.%s-%s', $versionNumber, $gitBranch, $hash);
return sprintf('%s.%s-%s', $this->versionNumber, $gitBranch, $hash);
} else {
$this->version = 'Unknown';
return $this->versionNumber;
}
}

Expand All @@ -36,12 +36,22 @@ public function printVersionForOutput()
}

/**
* Returns SquareBracket's version number. Originally named getBettyVersion().
* Returns the version number.
*
* @return string
*/
public function getVersionNumber(): string
{
return $this->versionNumber;
}

/**
* Returns the version string.
*
* @return string
*/
public function getVersionString(): string
{
return $this->version;
return $this->versionString;
}
}

0 comments on commit 4fabeeb

Please sign in to comment.