aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/common.inc.php23
-rw-r--r--include/functions.inc.php61
-rw-r--r--include/page_tail.php11
4 files changed, 75 insertions, 22 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 444ffd826..18ad85fb3 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -35,6 +35,8 @@ $selection = array_slice(
$page['nb_image_page']
);
+$selection = trigger_event('loc_index_thumbnails_selection', $selection);
+
if (count($selection) > 0)
{
$rank_of = array_flip($selection);
diff --git a/include/common.inc.php b/include/common.inc.php
index 158dbf1ef..378b9b4e0 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -192,28 +192,7 @@ if (defined('IN_ADMIN') and IN_ADMIN )
}
else
{ // Classic template
- $theme = $user['theme'];
-
- if (!isset($_SESSION['is_mobile']))
- {
- include_once(PHPWG_ROOT_PATH.'include/mdetect.php');
- $uagent_obj = new uagent_info();
- if ($_SESSION['is_mobile'] = $uagent_obj->DetectMobileLong())
- {
- $_SESSION['use_mobile_theme'] = !empty($conf['mobile_theme']);
- }
- }
- if ($_SESSION['is_mobile'])
- {
- if (isset($_REQUEST['mobile']))
- {
- $_SESSION['use_mobile_theme'] = get_boolean($_REQUEST['mobile']);
- }
- if ($_SESSION['use_mobile_theme'])
- {
- $theme = $conf['mobile_theme'];
- }
- }
+ $theme = mobile_theme() ? $conf['mobile_theme'] : $user['theme'];
$template = new Template(PHPWG_ROOT_PATH.'themes', $theme );
}
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
diff --git a/include/page_tail.php b/include/page_tail.php
index 5a8f8a724..14c6391fb 100644
--- a/include/page_tail.php
+++ b/include/page_tail.php
@@ -65,6 +65,17 @@ if ($conf['show_gt'])
$template->assign('debug', $debug_vars );
+//------------------------------------------------------------- mobile version
+if (get_device() != 'desktop')
+{
+ $template->assign('TOGGLE_MOBILE_THEME_URL',
+ add_url_params(
+ make_index_url(),
+ array('mobile' => mobile_theme() ? 'false' : 'true')
+ )
+ );
+}
+
trigger_action('loc_end_page_tail');
//
// Generate the page