Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ivantcholakov/codeigniter-user-agent-helper

User Agent Helper Functions
https://github.com/ivantcholakov/codeigniter-user-agent-helper

codeigniter php

Last synced: 2 months ago
JSON representation

User Agent Helper Functions

Awesome Lists containing this project

README

        

User Agent Helper Functions
===========================

This set of helper functions is aimed for convenience in use the CodeIgniter's
User_agent library. Tested on CodeIgniter 2.1.4 and CodeIgniter 3.0-dev (October, 2013).

Installation
------------

Place the file user_agent_helper.php within your application/helpers folder.

A Quick Test
------------

```php
$this->load->helper('user_agent');
var_dump(user_agent());
```

A Usage Example for Making an Adaptive HTML Boilerplate
--------------------------------------------------------

```php
if (!function_exists('template_enable_oldie')) {

/**
* This function decides whether additional assets within a html template
* to be loaded for supporting older versions of Internet Explorer.
* Create within your system the following configuration options:
* $config['ie_min_supported_version'] = 6; // 6, 7, 8, 9, 10, ...
* $config['load_assets_by_ua_detection'] = true; // or false
* @autor Ivan Tcholakov, 2013.
* @license The MIT License, http://opensource.org/licenses/MIT
* @return boolean
*/
function template_enable_oldie() {

$ie_min_supported = config_item('ie_min_supported_version');

if ($ie_min_supported < 9) {

if (config_item('load_assets_by_ua_detection')) {

ci()->load->helper('user_agent');

$browser = user_agent_ie();

if ($browser['is_ie']) {

if ($browser['ie_version'] < 9 &&
$browser['ie_version'] >= $ie_min_supported) {

return true;
}

return false;
}

return false;
}

return true;
}

return false;
}

}
```

Author: Ivan Tcholakov , 2012-2013.
License: The MIT License (MIT), http://opensource.org/licenses/MIT