Skip to content

Commit

Permalink
Ran php-cs-fixer.
Browse files Browse the repository at this point in the history
Updated future version number.
Related to discussion at serbanghita#137
  • Loading branch information
serbanghita committed Jul 30, 2013
1 parent 59400d0 commit 71f6c8b
Show file tree
Hide file tree
Showing 5 changed files with 861 additions and 881 deletions.
4 changes: 2 additions & 2 deletions Mobile_Detect.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @link Official page: http://mobiledetect.net
* GitHub Repository: https://github.com/serbanghita/Mobile-Detect
* Google Code Old Page: http://code.google.com/p/php-mobile-detect/
* @version 2.6.4
* @version 2.6.5
*/

class Mobile_Detect
Expand Down Expand Up @@ -68,7 +68,7 @@ class Mobile_Detect
* Stores the version number of the current release.
* @var array
*/
protected $scriptVersion = '2.6.4';
protected $scriptVersion = '2.6.5';

/**
* The User-Agent HTTP header is stored in here.
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
'source': 'demoVisitor'
},
success: function(r){
try{ console.log(r); } catch(e){ }
try { console.log(r); } catch (e) { }
}
});

Expand Down
92 changes: 41 additions & 51 deletions examples/session_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,78 +44,68 @@
*
*/


// This is mandatory if you're using sessions.
session_start();

// It's mandatory to include the library.
require_once '../Mobile_Detect.php';





/**
* Begin helper functions.
*/

// Your default site layouts.
// Update this array if you have fewer layout types.
function layoutTypes(){

return array('classic', 'mobile', 'tablet');
function layoutTypes()
{
return array('classic', 'mobile', 'tablet');

}

function initLayoutType(){
function initLayoutType()
{
// Safety check.
if (!class_exists('Mobile_Detect')) { return 'classic'; }

// Safety check.
if(!class_exists('Mobile_Detect')){ return 'classic'; }
$detect = new Mobile_Detect;
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();

$detect = new Mobile_Detect;
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();
$layoutTypes = layoutTypes();

// Set the layout type.
if ( isset($_GET['layoutType']) ) {

$layoutTypes = layoutTypes();
$layoutType = $_GET['layoutType'];

// Set the layout type.
if ( isset($_GET['layoutType']) ){
} else {

$layoutType = $_GET['layoutType'];
if (empty($_SESSION['layoutType'])) {

} else {
$layoutType = ($isMobile ? ($isTablet ? 'tablet' : 'mobile') : 'classic');

if(empty($_SESSION['layoutType'])){
} else {

$layoutType = ($isMobile ? ($isTablet ? 'tablet' : 'mobile') : 'classic');
$layoutType = $_SESSION['layoutType'];

} else {
}

$layoutType = $_SESSION['layoutType'];
}

}
// Fallback. If everything fails choose classic layout.
if ( !in_array($layoutType, $layoutTypes) ) { $layoutType = 'classic'; }

}
// Store the layout type for future use.
$_SESSION['layoutType'] = $layoutType;

// Fallback. If everything fails choose classic layout.
if( !in_array($layoutType, $layoutTypes) ){ $layoutType = 'classic'; }

// Store the layout type for future use.
$_SESSION['layoutType'] = $layoutType;

return $layoutType;
return $layoutType;

}

/**
* End helper functions.
*/





// Let's roll. Call this function!
$layoutType = initLayoutType();

Expand All @@ -129,28 +119,28 @@ function initLayoutType(){

<?php if(!isset($_GET['page'])): ?>

<!-- example page #1 -->
<h1>Demo page number one.</h1>
<p>You can go to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=two">two</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>
<p><b>Note:</b> When running this test using the same browser with multiple User-Agents, clear your cookies/session before each test.</p>
<!-- example page #1 -->
<h1>Demo page number one.</h1>
<p>You can go to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=two">two</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>
<p><b>Note:</b> When running this test using the same browser with multiple User-Agents, clear your cookies/session before each test.</p>

<?php endif; ?>

<?php if(isset($_GET['page']) && $_GET['page']=='two'): ?>

<!-- example page #2 -->
<h1>Demo page number two.</h1>
<p>You can go back to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>">one</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>
<!-- example page #2 -->
<h1>Demo page number two.</h1>
<p>You can go back to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>">one</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>

<?php endif; ?>

<!-- Footer links example. Change this as you like. -->
<?php foreach(layoutTypes() as $_layoutType): ?>
<?php if($_layoutType == $layoutType): ?>
<?php echo strtoupper($_layoutType); ?>
<?php else: ?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?layoutType=<?php echo $_layoutType; ?>"><?php echo strtoupper($_layoutType); ?></a>
<?php endif; ?>
<?php endforeach; ?>
<?php if($_layoutType == $layoutType): ?>
<?php echo strtoupper($_layoutType); ?>
<?php else: ?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?layoutType=<?php echo $_layoutType; ?>"><?php echo strtoupper($_layoutType); ?></a>
<?php endif; ?>
<?php endforeach;
44 changes: 22 additions & 22 deletions namespaced/Detection/MobileDetect.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
/**
* Little piece of PHP to make Mobile_Detect auto-loadable in PSR-0 compatible PHP autoloaders like
* the Symfony Universal ClassLoader by Fabien Potencier. Since PSR-0 handles an underscore in
* classnames (on the filesystem) as a slash, "Mobile_Detect.php" autoloaders will try to convert
* the classname and path to "Mobile\Detect.php". This script will ensure autoloading with:
* - Namespace: Detection
* - Classname: MobileDetect
* - Namespased: \Detection\MobileDetect
* - Autoload path: ./namespaced
* - Converted path: ./namespaced/Detection/MobileDetect.php
*
* Don't forget to use MobileDetect (instead of Mobile_Detect) as class in code when autoloading.
*
* Thanks to @WietseWind.
* For details please check: https://github.com/serbanghita/Mobile-Detect/pull/120
*/

namespace Detection;
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Mobile_Detect.php';

class MobileDetect extends \Mobile_Detect {}
<?php
/**
* Little piece of PHP to make Mobile_Detect auto-loadable in PSR-0 compatible PHP autoloaders like
* the Symfony Universal ClassLoader by Fabien Potencier. Since PSR-0 handles an underscore in
* classnames (on the filesystem) as a slash, "Mobile_Detect.php" autoloaders will try to convert
* the classname and path to "Mobile\Detect.php". This script will ensure autoloading with:
* - Namespace: Detection
* - Classname: MobileDetect
* - Namespased: \Detection\MobileDetect
* - Autoload path: ./namespaced
* - Converted path: ./namespaced/Detection/MobileDetect.php
*
* Don't forget to use MobileDetect (instead of Mobile_Detect) as class in code when autoloading.
*
* Thanks to @WietseWind.
* For details please check: https://github.com/serbanghita/Mobile-Detect/pull/120
*/

namespace Detection;
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Mobile_Detect.php';

class MobileDetect extends \Mobile_Detect {}
Loading

0 comments on commit 71f6c8b

Please sign in to comment.