aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2012-02-18 20:26:52 +0000
committerpatdenice <patdenice@piwigo.org>2012-02-18 20:26:52 +0000
commit26ed60c972da7e18325c35a62e72025d1a70fbf1 (patch)
treedbbd725d4b44402ec9c4b1b149db52c4fe886173 /include/functions.inc.php
parent4b696df2dad09a333ee41705e2236fb0d986e0c1 (diff)
feature:2577
Many improvements git-svn-id: http://piwigo.org/svn/trunk@13234 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 4a4677b8a..b977a6ef4 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1678,4 +1678,65 @@ function get_branch_from_version($version)
{
return implode('.', array_slice(explode('.', $version), 0, 2));
}
+
+/**
+ * return the device type: mobile, tablet or desktop
+ */
+function get_device()
+{
+ $device = pwg_get_session_var('device');
+
+ if (is_null($device))
+ {
+ include_once(PHPWG_ROOT_PATH.'include/mdetect.php');
+ $uagent_obj = new uagent_info();
+ if ($uagent_obj->DetectTierIphone())
+ {
+ $device = 'mobile';
+ }
+ elseif ($uagent_obj->DetectTierTablet())
+ {
+ $device = 'tablet';
+ }
+ else
+ {
+ $device = 'desktop';
+ }
+ pwg_set_session_var('device', $device);
+ }
+
+ return $device;
+}
+
+/**
+ * return true if mobile theme should be loaded
+ */
+function mobile_theme()
+{
+ global $conf;
+
+ if (empty($conf['mobile_theme']))
+ {
+ return false;
+ }
+
+ if (isset($_GET['mobile']))
+ {
+ $is_mobile_theme = get_boolean($_GET['mobile']);
+ pwg_set_session_var('mobile_theme', $is_mobile_theme);
+ unset($_GET['mobile']);
+ }
+ else
+ {
+ $is_mobile_theme = pwg_get_session_var('mobile_theme');
+ }
+
+ if (is_null($is_mobile_theme))
+ {
+ $is_mobile_theme = (get_device() == 'mobile');
+ pwg_set_session_var('mobile_theme', $is_mobile_theme);
+ }
+
+ return $is_mobile_theme;
+}
?> \ No newline at end of file