This repository has been archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from peldax/master
Tracy debug panel and replacement of MobileDetect
- Loading branch information
Showing
4 changed files
with
111 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* MobileDetectExtension.php | ||
* | ||
* @copyright More in license.md | ||
* @license http://www.ipublikuj.eu | ||
* @author Adam Kadlec http://www.ipublikuj.eu | ||
* @package iPublikuj:MobileDetect! | ||
* @subpackage DI | ||
* @since 1.0.0 | ||
* | ||
* @date 21.04.14 | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace IPub\MobileDetect\Diagnostics; | ||
|
||
/** | ||
* Mobile device detect tracy panel | ||
* | ||
* @package iPublikuj:MobileDetect! | ||
* @subpackage Diagnostics | ||
* | ||
* @author Václav Pelíšek <info@peldax.com> | ||
*/ | ||
final class Panel extends \Nette\Object implements \Tracy\IBarPanel | ||
{ | ||
/** @var \IPub\MobileDetect\MobileDetect | ||
*/ | ||
private $mobileDetect; | ||
|
||
public function register(\IPub\MobileDetect\MobileDetect $mobileDetect) | ||
{ | ||
$this->mobileDetect = $mobileDetect; | ||
|
||
\Tracy\Debugger::getBar()->addPanel($this, 'ipub.mobileDetect'); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Renders HTML code for custom tab. | ||
* | ||
* @return string | ||
*/ | ||
public function getTab() | ||
{ | ||
return '<span title="Mobile detect"><img width="16px" height="16px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAACNCAYAAAAeuFBXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFMzg3RTE0RTg0MUYxMUUyQkRDMEVDMzQ5RjcxOEI3OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowOUUwNjQ2QTg0MjAxMUUyQkRDMEVDMzQ5RjcxOEI3OCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkUzODdFMTRDODQxRjExRTJCREMwRUMzNDlG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UxAoAGBBvYh0FuVkybDQAvgYj/LOunOVf3ZL+12UHtTzwUpaT09d9+mQJca6E+vth/+S4FKutGMQXr+/usCXdoEfHJl0Fx+D1ja6fTCA6sCXdoEfPzzpIr78Oie9OKD18pbFJYa5o9+Glaxn4Ru7ix2degiit/8sV0IHgxe5tNp7aEzAh298JM/rDWXkwWU+kczFtL6w9cFOmrRH34fbZtuGuN0eHEk0FGLPnH5VHNZKajkG9td+uWlLYGOVvDxSwvN5bcCLet0euWRVYGOVvAH302qct/xXkqvHppELrCobbv6/YvLVdkHFlqPHurQUYp970LrkAersnkmHXn0lED3vdB3z7fdaaPCrfc8Xnss5DZeEcpRv/PtoLmsyfI2cztzMdKh+1rk29+0/8WuyPLfuDu9/viWDt23ML91bijM/0j7nseyDt23At88O6n8KIZ/Yym98cREh+5LmI99vSrMU7v0gg7dh8LGX5X2vsZ/ZT1tPBnmuFbcHzST0loz5rZPtBu7jVE9+nI+ysceVzlu3mz/9DsT98agGSFOtjgki1D8KcAASOpOloXu01cAAAAASUVORK5CYII=" />' | ||
. $this->mobileDetect->view() . ' / ' . $this->mobileDetect->platform() . '</span>'; | ||
} | ||
|
||
/** | ||
* Renders HTML code for custom panel. | ||
* | ||
* @return string | ||
*/ | ||
public function getPanel() | ||
{ | ||
$h = 'htmlSpecialChars'; | ||
|
||
$panel = []; | ||
|
||
$panel[] = '<h2>Original User agent header</h2>'; | ||
$panel[] = '<p>' . $h($this->mobileDetect->getUserAgent()) . '</p>'; | ||
|
||
$properties = ['view', 'platform', 'platformVersion', 'device', 'browser', 'browserVersion']; | ||
|
||
$panel[] = '<table style="width:100%">'; | ||
foreach ($properties as $property) | ||
{ | ||
$panel[] = '<tr><th>' . ucfirst($property) . '</th><td>' . $h($this->mobileDetect->{$property}() ?: '') . '</td></tr>'; | ||
} | ||
$panel[] = '</table>'; | ||
|
||
return empty($panel) ? '' : | ||
'<h1>View: '.$this->mobileDetect->view() . ', OS: ' . $this->mobileDetect->platform().'</h1>' . | ||
'<div class="nette-inner tracy-inner ipub-MobileDetectPanel" style="min-width:500px">' . implode($panel) . '</div>' . | ||
'<style> | ||
#nette-debug .ipub-MobileDetectPanel h2, | ||
#tracy-debug .ipub-MobileDetectPanel h2 {font-size: 17px;} | ||
</style>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters