source: tags/2.4.0/themes/smartpocket/themeconf.inc.php @ 15938

Last change on this file since 15938 was 13545, checked in by patdenice, 12 years ago

Automaticaly set better derivative params for mobile theme according to screen size.

File size: 1.4 KB
Line 
1<?php
2/*
3Theme Name: Smart Pocket
4Version: 2.4.0
5Description: Mobile theme.
6Theme URI: http://piwigo.org/ext/extension_view.php?eid=599
7Author: P@t
8Author URI: http://piwigo.org
9*/
10
11$themeconf = array(
12  'mobile' => true,
13);
14
15// Redirect if page is not compatible with mobile theme
16if (!in_array(script_basename(), array('index', 'register', 'profile', 'identification')))
17  redirect(duplicate_index_url());
18
19//Retrive all pictures on thumbnails page
20add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails');
21
22function sp_select_all_thumbnails($selection)
23{
24  global $page, $template;
25
26  $template->assign('page_selection', array_flip($selection));
27
28  return $page['items'];
29}
30
31// Get better derive parameters for screen size
32if (!empty($_COOKIE['screen_size']))
33{
34  $screen_size = explode('x', $_COOKIE['screen_size']);
35  $derivative_params = new ImageStdParams;
36  $derivative_params->load_from_db();
37  $type = IMG_LARGE;
38
39  foreach ($derivative_params->get_all_type_map() as $type => $map)
40  {
41    if (max($map->sizing->ideal_size) >= max($screen_size) and min($map->sizing->ideal_size) >= min($screen_size))
42      break;
43  }
44  pwg_set_session_var('sp_picture_deriv', $type);
45}
46
47$this->assign('picture_derivative_params', ImageStdParams::get_by_type(pwg_get_session_var('sp_picture_deriv', IMG_LARGE)));
48$this->assign('thumbnail_derivative_params', ImageStdParams::get_by_type(IMG_SQUARE));
49
50?>
Note: See TracBrowser for help on using the repository browser.