diff options
-rw-r--r-- | index.php | 8 | ||||
-rw-r--r-- | libraries/classes/Display/GitRevision.php | 97 | ||||
-rw-r--r-- | libraries/display_git_revision.lib.php | 87 |
3 files changed, 99 insertions, 93 deletions
@@ -8,6 +8,7 @@ use PhpMyAdmin\Charsets; use PhpMyAdmin\Core; +use PhpMyAdmin\Display\GitRevision; use PhpMyAdmin\LanguageManager; use PhpMyAdmin\Message; use PhpMyAdmin\RecentFavoriteTable; @@ -23,11 +24,6 @@ use PhpMyAdmin\Url; require_once 'libraries/common.inc.php'; /** - * display Git revision if requested - */ -require_once 'libraries/display_git_revision.lib.php'; - -/** * pass variables to child pages */ $drops = array( @@ -98,7 +94,7 @@ if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) { if ($GLOBALS['PMA_Config']->isGitRevision()) { if (isset($_REQUEST['git_revision']) && $response->isAjax()) { - PMA_printGitRevision(); + GitRevision::print(); exit; } echo '<div id="is_git_revision"></div>'; diff --git a/libraries/classes/Display/GitRevision.php b/libraries/classes/Display/GitRevision.php new file mode 100644 index 0000000000..f20939e6e2 --- /dev/null +++ b/libraries/classes/Display/GitRevision.php @@ -0,0 +1,97 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Displays git revision + * + * @package PhpMyAdmin + */ +namespace PhpMyAdmin\Display; + +use PhpMyAdmin\Core; +use PhpMyAdmin\Response; +use PhpMyAdmin\Util; + +/** + * PhpMyAdmin\Display\GitRevision class + * + * @package PhpMyAdmin + */ +class GitRevision +{ + /** + * Prints details about the current Git commit revision + * + * @return void + */ + public static function print() + { + if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) { + $response = Response::getInstance(); + $response->setRequestStatus(false); + return; + } + + // load revision data from repo + $GLOBALS['PMA_Config']->checkGitRevision(); + + // if using a remote commit fast-forwarded, link to GitHub + $commit_hash = substr( + $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), + 0, + 7 + ); + $commit_hash = '<strong title="' + . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) + . '">' . $commit_hash . '</strong>'; + if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) { + $commit_hash = '<a href="' + . Core::linkURL( + 'https://github.com/phpmyadmin/phpmyadmin/commit/' + . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH') + ) + . '" rel="noopener noreferrer" target="_blank">' . $commit_hash . '</a>'; + } + + $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH'); + if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) { + $branch = '<a href="' + . Core::linkURL( + 'https://github.com/phpmyadmin/phpmyadmin/tree/' + . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH') + ) + . '" rel="noopener noreferrer" target="_blank">' . $branch . '</a>'; + } + if ($branch !== false) { + $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch); + } else { + $branch = $commit_hash . ' (' . __('no branch') . ')'; + } + + $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER'); + $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR'); + PMA_printListItem( + __('Git revision:') . ' ' + . $branch . ',<br /> ' + . sprintf( + __('committed on %1$s by %2$s'), + Util::localisedDate(strtotime($committer['date'])), + '<a href="' . Core::linkURL( + 'mailto:' . htmlspecialchars($committer['email']) + ) . '">' + . htmlspecialchars($committer['name']) . '</a>' + ) + . ($author != $committer + ? ', <br />' + . sprintf( + __('authored on %1$s by %2$s'), + Util::localisedDate(strtotime($author['date'])), + '<a href="' . Core::linkURL( + 'mailto:' . htmlspecialchars($author['email']) + ) . '">' + . htmlspecialchars($author['name']) . '</a>' + ) + : ''), + 'li_pma_version_git', null, null, null + ); + } +} diff --git a/libraries/display_git_revision.lib.php b/libraries/display_git_revision.lib.php deleted file mode 100644 index c2f3521e5f..0000000000 --- a/libraries/display_git_revision.lib.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Displays form for password change - * - * @package PhpMyAdmin - */ - -use PhpMyAdmin\Core; -use PhpMyAdmin\Response; - -/** -* Prints details about the current Git commit revision -* -* @return void -*/ -function PMA_printGitRevision() -{ - if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) { - $response = Response::getInstance(); - $response->setRequestStatus(false); - return; - } - - // load revision data from repo - $GLOBALS['PMA_Config']->checkGitRevision(); - - // if using a remote commit fast-forwarded, link to GitHub - $commit_hash = substr( - $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), - 0, - 7 - ); - $commit_hash = '<strong title="' - . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) - . '">' . $commit_hash . '</strong>'; - if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) { - $commit_hash = '<a href="' - . Core::linkURL( - 'https://github.com/phpmyadmin/phpmyadmin/commit/' - . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH') - ) - . '" rel="noopener noreferrer" target="_blank">' . $commit_hash . '</a>'; - } - - $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH'); - if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) { - $branch = '<a href="' - . Core::linkURL( - 'https://github.com/phpmyadmin/phpmyadmin/tree/' - . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH') - ) - . '" rel="noopener noreferrer" target="_blank">' . $branch . '</a>'; - } - if ($branch !== false) { - $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch); - } else { - $branch = $commit_hash . ' (' . __('no branch') . ')'; - } - - $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER'); - $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR'); - PMA_printListItem( - __('Git revision:') . ' ' - . $branch . ',<br /> ' - . sprintf( - __('committed on %1$s by %2$s'), - PhpMyAdmin\Util::localisedDate(strtotime($committer['date'])), - '<a href="' . Core::linkURL( - 'mailto:' . htmlspecialchars($committer['email']) - ) . '">' - . htmlspecialchars($committer['name']) . '</a>' - ) - . ($author != $committer - ? ', <br />' - . sprintf( - __('authored on %1$s by %2$s'), - PhpMyAdmin\Util::localisedDate(strtotime($author['date'])), - '<a href="' . Core::linkURL( - 'mailto:' . htmlspecialchars($author['email']) - ) . '">' - . htmlspecialchars($author['name']) . '</a>' - ) - : ''), - 'li_pma_version_git', null, null, null - ); -} |