Skip to content

Commit f0b61ab

Browse files
committed
Added script version.
Added/updated license information.
1 parent 5808a19 commit f0b61ab

File tree

4 files changed

+54
-17
lines changed

4 files changed

+54
-17
lines changed

Mobile_Detect.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
*
2626
* @author Serban Ghita <serbanghita@gmail.com>
2727
* Victor Stanciu <vic.stanciu@gmail.com> (until v.1.0)
28-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
28+
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
2929
* @link Official page: http://mobiledetect.net
3030
* GitHub Repository: https://github.com/serbanghita/Mobile-Detect
3131
* Google Code Old Page: http://code.google.com/p/php-mobile-detect/
32-
* @version 2.5.3 (GitHub Release)
3332
*/
3433

3534
class Mobile_Detect {
3635

36+
protected $scriptVersion = '2.5.4';
37+
3738
// External info.
3839
protected $userAgent = null;
3940
protected $httpHeaders;
@@ -242,6 +243,19 @@ function __construct(){
242243

243244
}
244245

246+
247+
/**
248+
* Get the current script version.
249+
* This is useful for the demo.php file,
250+
* so people can check on what version they are testing
251+
* for mobile devices.
252+
*/
253+
public function getScriptVersion(){
254+
255+
return $this->scriptVersion;
256+
257+
}
258+
245259
public function setHttpHeaders($httpHeaders = null){
246260

247261
if(!empty($httpHeaders)){

demo.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@
2424
*
2525
*
2626
* @author Serban Ghita <serbanghita@gmail.com>
27-
* Victor Stanciu <vic.stanciu@gmail.com> (until v.1.0)
28-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
27+
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
28+
*
2929
*/
30+
31+
require_once 'Mobile_Detect.php';
32+
$detect = new Mobile_Detect;
33+
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
34+
$scriptVersion = $detect->getScriptVersion();
35+
3036
?><!DOCTYPE html>
3137
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
3238
<head>
@@ -40,6 +46,7 @@
4046
table th { text-align:left; }
4147
a { color: #0088cc; text-decoration: underline; }
4248
a:hover { color: #005580; text-decoration: underline; }
49+
header h1 small { font-size:small; }
4350
section { margin-bottom:2em; }
4451
section h1 { font-size:100%; }
4552
.infoText { font-size:85%; }
@@ -136,17 +143,12 @@
136143
<body>
137144

138145
<header>
139-
<h1><a href="https://github.com/serbanghita/Mobile-Detect">Mobile_Detect</a></h1>
146+
<h1><a href="https://github.com/serbanghita/Mobile-Detect">Mobile_Detect</a> <small>v. <?php echo $scriptVersion; ?></small></h1>
140147
<p class="infoText">The lightweight PHP class for detecting mobile devices.</p>
141148
</header>
142149

143150
<!-- copy to GitHub with a couple of changes -->
144151
<section>
145-
<?php
146-
require_once 'Mobile_Detect.php';
147-
$detect = new Mobile_Detect;
148-
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
149-
?>
150152

151153
<p>This is a <b><?php echo $deviceType; ?></b>. Your UA is <b class="<?php echo $deviceType; ?>"><?php echo htmlentities($_SERVER['HTTP_USER_AGENT']); ?></b></p>
152154

tests/BasicsTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11
<?php
2+
/**
3+
* MIT License
4+
* ===========
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining
7+
* a copy of this software and associated documentation files (the
8+
* "Software"), to deal in the Software without restriction, including
9+
* without limitation the rights to use, copy, modify, merge, publish,
10+
* distribute, sublicense, and/or sell copies of the Software, and to
11+
* permit persons to whom the Software is furnished to do so, subject to
12+
* the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included
15+
* in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*
25+
*
26+
* @author Serban Ghita <serbanghita@gmail.com>
27+
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
28+
* @link http://mobiledetect.net
29+
*/
230
class BasicTest extends PHPUnit_Framework_TestCase {
331

432
protected function setUp(){

tests/phpunit.xml

-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,4 @@
1111
<directory>./</directory>
1212
</testsuite>
1313

14-
<!--
15-
<filter>
16-
<whitelist addUncoveredFilesFromWhitelist="true">
17-
<directory suffix=".php">../</directory>
18-
</whitelist>
19-
</filter>
20-
-->
2114
</phpunit>

0 commit comments

Comments
 (0)