diff options
author | sgiehl <stefan@piwik.org> | 2014-01-20 17:17:28 +0400 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2014-01-20 17:17:28 +0400 |
commit | 481030b75df0beaed946805a2430f6de66a19979 (patch) | |
tree | f57c4e730a557469b349afa14127eb84e7e689f5 /plugins | |
parent | 5b1c537f619834608c6e2481448ce8f344660e7c (diff) |
added possibility for admins to check their/any user agent for detectable os/browser/device
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/DevicesDetection/Controller.php | 35 | ||||
-rw-r--r-- | plugins/DevicesDetection/DevicesDetection.php | 12 | ||||
-rw-r--r-- | plugins/DevicesDetection/lang/en.json | 5 | ||||
-rw-r--r-- | plugins/DevicesDetection/templates/detection.twig | 72 |
4 files changed, 123 insertions, 1 deletions
diff --git a/plugins/DevicesDetection/Controller.php b/plugins/DevicesDetection/Controller.php index c37efe555a..d1dec5781e 100644 --- a/plugins/DevicesDetection/Controller.php +++ b/plugins/DevicesDetection/Controller.php @@ -13,6 +13,7 @@ namespace Piwik\Plugins\DevicesDetection; use Piwik\Common; use Piwik\Db; use Piwik\Piwik; +use Piwik\Plugin\ControllerAdmin; use Piwik\View; use Piwik\ViewDataTable\Factory; use UserAgentParserEnhanced; @@ -91,4 +92,38 @@ class Controller extends \Piwik\Plugin\Controller WHERE idvisit = " . $idVisit; Db::query($q); } + + public function deviceDetection() + { + Piwik::checkUserHasSomeAdminAccess(); + + $view = new View('@DevicesDetection/detection'); + $this->setBasicVariablesView($view); + ControllerAdmin::setBasicVariablesAdminView($view); + + $userAgent = Common::getRequestVar('ua', $_SERVER['HTTP_USER_AGENT'], 'string'); + + $parsedUA = UserAgentParserEnhanced::getInfoFromUserAgent($userAgent); + + $view->userAgent = $userAgent; + $view->browser_name = $parsedUA['browser']['name']; + $view->browser_short_name = $parsedUA['browser']['short_name']; + $view->browser_version = $parsedUA['browser']['version']; + $view->browser_logo = getBrowserLogoExtended($parsedUA['browser']['short_name']); + $view->browser_family = $parsedUA['browser_family']; + $view->browser_family_logo = getBrowserFamilyLogoExtended($parsedUA['browser_family']); + $view->os_name = $parsedUA['os']['name']; + $view->os_logo = getOsLogoExtended($parsedUA['os']['short_name']); + $view->os_short_name = $parsedUA['os']['short_name']; + $view->os_family = $parsedUA['os_family']; + $view->os_family_logo = getOsFamilyLogoExtended($parsedUA['os_family']); + $view->os_version = $parsedUA['os']['version']; + $view->device_type = $parsedUA['device']['type']; + $view->device_type_logo = getDeviceTypeLogo(ucfirst($view->device_type)); + $view->device_model = $parsedUA['device']['model']; + $view->device_brand = getDeviceBrandLabel($parsedUA['device']['brand']); + $view->device_brand_logo = getBrandLogo($view->device_brand); + + return $view->render(); + } } diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 1180db2645..7731e63f30 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -17,6 +17,7 @@ use Piwik\ArchiveProcessor; use Piwik\Common; use Piwik\Config; use Piwik\Db; +use Piwik\Menu\MenuAdmin; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -94,6 +95,7 @@ class DevicesDetection extends \Piwik\Plugin { return array( 'Menu.Reporting.addItems' => 'addMenu', + 'Menu.Admin.addItems' => 'addAdminMenu', 'Tracker.newVisitorInformation' => 'parseMobileVisitData', 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', @@ -102,6 +104,16 @@ class DevicesDetection extends \Piwik\Plugin ); } + public function addAdminMenu() + { + MenuAdmin::getInstance()->add( + 'CoreAdminHome_MenuDiagnostic', 'DevicesDetection_DeviceDetection', + array('module' => 'DevicesDetection', 'action' => 'deviceDetection'), + Piwik::isUserHasSomeAdminAccess(), + $order = 40 + ); + } + /** * Defines API reports. * Also used to define Widgets, and Segment(s) diff --git a/plugins/DevicesDetection/lang/en.json b/plugins/DevicesDetection/lang/en.json index 2591e17651..ce823b3a0d 100644 --- a/plugins/DevicesDetection/lang/en.json +++ b/plugins/DevicesDetection/lang/en.json @@ -13,6 +13,9 @@ "BrowserVersions": "Browser versions", "DeviceType": "Device type", "DeviceBrand": "Device brand", - "DeviceModel": "Device model" + "DeviceModel": "Device model", + "DeviceDetection": "Device detection", + "Device": "Device", + "UserAgent": "User-Agent" } } diff --git a/plugins/DevicesDetection/templates/detection.twig b/plugins/DevicesDetection/templates/detection.twig new file mode 100644 index 0000000000..9930ff0dc9 --- /dev/null +++ b/plugins/DevicesDetection/templates/detection.twig @@ -0,0 +1,72 @@ +{% extends 'admin.twig' %} + +{% block content %} + <style type="text/css"> + + textarea { + width: 700px; + display: block; + } + + .detection td { + width: 50%; + } + + </style> + <h1>{{ 'DevicesDetection_DeviceDetection'|translate }}</h1> + + <h2>{{ 'DevicesDetection_UserAgent'|translate }}</h2> + <form action="{{ linkTo({}) }}" method="POST"> + <textarea name="ua">{{ userAgent }}</textarea> + <input type="submit" value="{{ 'General_Refresh'|translate }}" /> + </form> + + <h2>{{ 'UserSettings_ColumnOperatingSystem'|translate }}</h2> + <table class="dataTable detection"> + <tr> + <td>{{ 'General_Name'|translate }}</td> + <td><img src="{{ os_logo }}" />{{ os_name }}</td> + </tr> + <tr> + <td>{{ 'CorePluginsAdmin_Version'|translate }}</td> + <td>{{ os_version }}</td> + </tr> + <tr> + <td>{{ 'UserSettings_OperatingSystemFamily'|translate }}</td> + <td><img src="{{ os_family_logo }}" />{{ os_family }}</td> + </tr> + </table> + + <h2>{{ 'UserSettings_ColumnBrowser'|translate }}</h2> + <table class="dataTable detection"> + <tr> + <td>{{ 'General_Name'|translate }}</td> + <td><img src="{{ browser_logo }}" />{{ browser_name }}</td> + </tr> + <tr> + <td>{{ 'CorePluginsAdmin_Version'|translate }}</td> + <td>{{ browser_version }}</td> + </tr> + <tr> + <td>{{ 'UserSettings_ColumnBrowserFamily'|translate }}</td> + <td><img src="{{ browser_family_logo }}" />{{ browser_family }}</td> + </tr> + </table> + + <h2>{{ 'DevicesDetection_Device'|translate }}</h2> + <table class="dataTable detection"> + <tr> + <td>{{ 'DevicesDetection_dataTableLabelTypes'|translate }}</td> + <td><img src="{{ device_type_logo }}" />{{ device_type }}</td> + </tr> + <tr> + <td>{{ 'DevicesDetection_dataTableLabelBrands'|translate }}</td> + <td><img src="{{ device_brand_logo }}" />{{ device_brand }}</td> + </tr> + <tr> + <td>{{ 'DevicesDetection_dataTableLabelModels'|translate }}</td> + <td>{{ device_model }}</td> + </tr> + </table> + +{% endblock %} |