Skip to content

Commit

Permalink
feat: add version number feature for backend footer
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Mar 11, 2023
1 parent fa7f91a commit 95f18eb
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,25 @@ public function basename($file)
public function changeFooter()
{
if ($this->wire->page->template != 'admin') return;
$str = $this->wire->config->httpHost;
$time = date("Y-m-d H:i:s", filemtime($this->wire->config->paths->root));
if ($this->wire->user->isSuperuser()) {
$dir = $this->wire->config->paths->root;
$str = "<span title='$dir @ $time' uk-tooltip>$str</span>";
$str = "";

if ($this->addHost) {
$str = $this->wire->config->httpHost;
$time = date("Y-m-d H:i:s", filemtime($this->wire->config->paths->root));
if ($this->wire->user->isSuperuser()) {
$dir = $this->wire->config->paths->root;
$str = "<span title='$dir @ $time' uk-tooltip>$str</span>";
}
}

// add version number if package.json is found in root
$f = $this->wire->config->paths->root . "package.json";
if ($this->addVersion and file_exists($f)) {
$version = json_decode(file_get_contents($f))->version;
$str .= " <small>v$version</small>";
}

if (!$str) return;
$this->wire->addHookAfter('AdminThemeUikit::renderFile', function ($event) use ($str) {
$file = $event->arguments(0); // full path/file being rendered
if (basename($file) !== '_footer.php') return;
Expand Down Expand Up @@ -4146,9 +4159,21 @@ public function getModuleConfigInputfields($inputfields)
'name' => 'addXdebugLauncher',
'label' => 'Add xDebug launcher file for DDEV to .vscode folder',
'notes' => 'All you have to do to use xDebug is "ddev xdebug on" and then start an xDebug session from within VSCode - see [docs](https://ddev.readthedocs.io/en/latest/users/debugging-profiling/step-debugging/#visual-studio-code-vs-code-debugging-setup)',
'collapsed' => Inputfield::collapsedBlank,
'checked' => $this->addXdebugLauncher ? 'checked' : '',
]);
$inputfields->add([
'type' => 'checkbox',
'name' => 'addHost',
'label' => 'Add hostname to the PW admin footer',
'checked' => $this->addHost ? 'checked' : '',
'notes' => 'Superusers will also see a the root folders name and modified date on hover in a tooltip!',
]);
$inputfields->add([
'type' => 'checkbox',
'name' => 'addVersion',
'label' => 'Add version number from package.json in root folder to the PW admin footer',
'checked' => $this->addVersion ? 'checked' : '',
]);

$this->profileExecute();
$f = new InputfieldSelect();
Expand Down

0 comments on commit 95f18eb

Please sign in to comment.