source: trunk/themes/smartpocket/themeconf.inc.php @ 26638

Last change on this file since 26638 was 26638, checked in by ddtddt, 10 years ago

[Trunk] - theme 2.5 -> 2.6

File size: 4.0 KB
Line 
1<?php
2/*
3Theme Name: Smart Pocket
4Version: 2.6.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// Need upgrade?
16global $conf;
17include(PHPWG_THEMES_PATH.'smartpocket/admin/upgrade.inc.php');
18
19
20// Redirect if page is not compatible with mobile theme
21/*if (!in_array(script_basename(), array('index', 'register', 'profile', 'identification', 'ws', 'admin')))
22  redirect(duplicate_index_url());
23*/
24
25
26class SPThumbPicker
27{
28  var $candidates;
29  var $default;
30  var $height;
31 
32  function init($height)
33  {
34    $this->candidates = array();
35    foreach( ImageStdParams::get_defined_type_map() as $params)
36    {
37      if ($params->max_height() < $height || $params->sizing->max_crop)
38        continue;
39      if ($params->max_height() > 3*$height)
40        break;
41      $this->candidates[] = $params;
42    }
43    $this->default = ImageStdParams::get_custom($height*3, $height, 1, 0, $height );
44    $this->height = $height;
45  }
46 
47  function pick($src_image)
48  {
49    $ok = false;
50    foreach($this->candidates as $candidate)
51    {
52      $deriv = new DerivativeImage($candidate, $src_image);
53      $size = $deriv->get_size();
54      if ($size[1]>=$row_height-2)
55      {
56        $ok = true;
57        break;
58      }
59    }
60    if (!$ok)
61    {
62      $deriv = new DerivativeImage($this->default, $src_image);
63    }
64    return $deriv;
65  }
66}
67
68//Retrive all pictures on thumbnails page
69add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails');
70
71function sp_select_all_thumbnails($selection)
72{
73  global $page, $template;
74
75  $template->assign('page_selection', array_flip($selection));
76  $template->assign('thumb_picker', new SPThumbPicker() );
77  return $page['items'];
78}
79
80// Retrive all categories on thumbnails page
81add_event_handler('loc_end_index_category_thumbnails', 'sp_select_all_categories');
82
83function sp_select_all_categories($selection)
84{
85  global $tpl_thumbnails_var;
86  return $tpl_thumbnails_var;
87}
88
89// Get better derive parameters for screen size
90$type = IMG_LARGE;
91if (!empty($_COOKIE['screen_size']))
92{
93  $screen_size = explode('x', $_COOKIE['screen_size']);
94  foreach (ImageStdParams::get_all_type_map() as $type => $map)
95  {
96    if (max($map->sizing->ideal_size) >= max($screen_size) and min($map->sizing->ideal_size) >= min($screen_size))
97      break;
98  }
99}
100
101$this->assign('picture_derivative_params', ImageStdParams::get_by_type($type));
102$this->assign('thumbnail_derivative_params', ImageStdParams::get_by_type(IMG_SQUARE));
103
104//------------------------------------------------------------- mobile version & theme config
105add_event_handler('init', 'mobile_link');
106
107function mobile_link()
108{
109  global $template, $conf;
110  $config = unserialize( $conf['smartpocket'] );
111  $template->assign( 'smartpocket', $config );
112  if ( !empty($conf['mobile_theme']) && (get_device() != 'desktop' || mobile_theme()))
113  {
114    $template->assign(array(
115                            'TOGGLE_MOBILE_THEME_URL' => add_url_params(duplicate_index_url(),array('mobile' => mobile_theme() ? 'false' : 'true')),
116      ));
117  }
118}
119
120
121if ( !function_exists( 'add_menu_on_public_pages' ) ) { 
122  if ( defined('IN_ADMIN') and IN_ADMIN ) return false; 
123  add_event_handler('loc_after_page_header', 'add_menu_on_public_pages', 20); 
124
125  function  add_menu_on_public_pages() { 
126    if ( function_exists( 'initialize_menu') ) return false; # The current page has already the menu 
127    global $template, $page, $conf; 
128    if ( isset($page['body_id']) and $page['body_id']=="thePicturePage" ) 
129    {           
130      $template->set_filenames(array( 
131            'add_menu_on_public_pages' => dirname(__FILE__) . '/template/add_menu_on_public_pages.tpl', 
132      )); 
133      include_once(PHPWG_ROOT_PATH.'include/menubar.inc.php'); 
134      $template->parse('add_menu_on_public_pages');
135    }
136     
137     
138  } 
139} 
140
141
142?>
Note: See TracBrowser for help on using the repository browser.