From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../libraries/classes/Display/GitRevision.php | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 srcs/phpmyadmin/libraries/classes/Display/GitRevision.php (limited to 'srcs/phpmyadmin/libraries/classes/Display/GitRevision.php') diff --git a/srcs/phpmyadmin/libraries/classes/Display/GitRevision.php b/srcs/phpmyadmin/libraries/classes/Display/GitRevision.php new file mode 100644 index 0000000..0a20f0e --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Display/GitRevision.php @@ -0,0 +1,144 @@ +response = $response; + $this->config = $config; + $this->template = $template; + } + + /** + * Returns details about the current Git commit revision + * + * @return string HTML + */ + public function display(): string + { + // load revision data from repo + $this->config->checkGitRevision(); + + if (! $this->config->get('PMA_VERSION_GIT')) { + $this->response->setRequestStatus(false); + return ''; + } + + // if using a remote commit fast-forwarded, link to GitHub + $commitHash = substr( + $this->config->get('PMA_VERSION_GIT_COMMITHASH'), + 0, + 7 + ); + $commitHash = '' . htmlspecialchars($commitHash) . ''; + if ($this->config->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) { + $commitHash = '' . $commitHash . ''; + } + + $branch = $this->config->get('PMA_VERSION_GIT_BRANCH'); + $isRemoteBranch = $this->config->get('PMA_VERSION_GIT_ISREMOTEBRANCH'); + if ($isRemoteBranch) { + $branch = '' . htmlspecialchars($branch) . ''; + } + if ($branch !== false) { + $branch = sprintf( + __('%1$s from %2$s branch'), + $commitHash, + $isRemoteBranch ? $branch : htmlspecialchars($branch) + ); + } else { + $branch = $commitHash . ' (' . __('no branch') . ')'; + } + + $committer = $this->config->get('PMA_VERSION_GIT_COMMITTER'); + $author = $this->config->get('PMA_VERSION_GIT_AUTHOR'); + + $name = __('Git revision:') . ' ' + . $branch . ',
' + . sprintf( + __('committed on %1$s by %2$s'), + Util::localisedDate(strtotime($committer['date'])), + '' + . htmlspecialchars($committer['name']) . '' + ) + . ($author != $committer + ? ',
' + . sprintf( + __('authored on %1$s by %2$s'), + Util::localisedDate(strtotime($author['date'])), + '' + . htmlspecialchars($author['name']) . '' + ) + : ''); + + return $this->template->render('list/item', [ + 'content' => $name, + 'id' => 'li_pma_version_git', + 'class' => null, + 'url' => [ + 'href' => null, + 'target' => null, + 'id' => null, + 'class' => null, + ], + 'mysql_help_page' => null, + ]); + } +} -- cgit