From 26ed60c972da7e18325c35a62e72025d1a70fbf1 Mon Sep 17 00:00:00 2001 From: patdenice Date: Sat, 18 Feb 2012 20:26:52 +0000 Subject: feature:2577 Many improvements git-svn-id: http://piwigo.org/svn/trunk@13234 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/category_default.inc.php | 2 + include/common.inc.php | 23 +--------- include/functions.inc.php | 61 +++++++++++++++++++++++++ include/page_tail.php | 11 +++++ language/en_UK/admin.lang.php | 1 - language/en_UK/common.lang.php | 3 ++ language/fr_FR/admin.lang.php | 1 - language/fr_FR/common.lang.php | 3 ++ themes/default/template/footer.tpl | 3 ++ themes/smartpocket/template/footer.tpl | 17 ++++++- themes/smartpocket/template/header.tpl | 4 +- themes/smartpocket/template/index.tpl | 2 +- themes/smartpocket/template/infos_errors.tpl | 32 +++++++------ themes/smartpocket/template/menubar.tpl | 5 +- themes/smartpocket/template/navigation_bar.tpl | 14 ++++++ themes/smartpocket/template/profile.tpl | 2 +- themes/smartpocket/template/profile_content.tpl | 7 ++- themes/smartpocket/template/thumbnails.tpl | 25 +++++++--- themes/smartpocket/theme.css | 10 +++- themes/smartpocket/themeconf.inc.php | 13 ++++++ 20 files changed, 184 insertions(+), 55 deletions(-) create mode 100644 themes/smartpocket/template/navigation_bar.tpl 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 diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index f1cf6685d..2fada1f0e 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -846,5 +846,4 @@ $lang['Not cropped correctly?'] = 'Not cropped correctly?'; $lang['Center of interest'] = 'Center of interest'; $lang['Move to album'] = 'Move to album'; $lang['You can activate only one mobile theme.'] = 'You can activate only one mobile theme.'; -$lang['mobile'] = 'mobile'; ?> \ No newline at end of file diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php index 520268f8d..6695038d9 100644 --- a/language/en_UK/common.lang.php +++ b/language/en_UK/common.lang.php @@ -383,4 +383,7 @@ $lang['Password: %s'] = 'Password: %s'; $lang['Username: %s'] = 'Username: %s'; $lang['If you think you\'ve received this email in error, please contact us at %s'] = 'If you think you\'ve received this email in error, please contact us at %s'; $lang['Photo sizes'] = 'Photo sizes'; +$lang['View in'] = 'View in'; +$lang['Mobile'] = 'Mobile'; +$lang['Desktop'] = 'Desktop'; ?> \ No newline at end of file diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index 5a8e2fb7d..4aa787dda 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -844,7 +844,6 @@ $lang['This album contains no photo.'] = 'Cet album ne contient pas de photo.'; $lang['%s has been successfully updated.'] = '%s a été mis à jour avec succès.'; $lang['Move to album'] = 'Déplacer vers l\'album'; $lang['You can activate only one mobile theme.'] = 'Vous ne pouvez activer qu\'un seul thème mobile.'; -$lang['mobile'] = 'mobile'; $lang['Center of interest'] = 'Centre d\'interêt'; $lang['Not cropped correctly?'] = 'La photo n\'est pas recadrée corectement ?'; $lang['Photo name'] = 'Nom de la photo'; diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php index 0501e4c8e..1cc1f1ec8 100644 --- a/language/fr_FR/common.lang.php +++ b/language/fr_FR/common.lang.php @@ -383,4 +383,7 @@ $lang['xlarge'] = "XLarge"; $lang['xxlarge'] = "XXLarge"; $lang['Show latest comments first'] = 'Montrer les commentaires les plus récents en premier'; $lang['Show oldest comments first'] = 'Montrer les commentaires les plus anciens en premier'; +$lang['View in'] = 'Affichage'; +$lang['Mobile'] = 'Mobile'; +$lang['Desktop'] = 'Classique'; ?> \ No newline at end of file diff --git a/themes/default/template/footer.tpl b/themes/default/template/footer.tpl index cf2f41a36..926a49dc0 100644 --- a/themes/default/template/footer.tpl +++ b/themes/default/template/footer.tpl @@ -13,6 +13,9 @@ - {'Contact'|@translate} {'Webmaster'|@translate} {/if} + {if isset($TOGGLE_MOBILE_THEME_URL)} + - {'Display'|@translate} : {'Mobile'|@translate} | {'Classic'|@translate} + {/if} {get_combined_scripts load='footer'} diff --git a/themes/smartpocket/template/footer.tpl b/themes/smartpocket/template/footer.tpl index 3de169077..5dec6da88 100644 --- a/themes/smartpocket/template/footer.tpl +++ b/themes/smartpocket/template/footer.tpl @@ -1,4 +1,19 @@ - +{if !empty($navbar)} +{include file='navigation_bar.tpl'|@get_extent:'navbar'} +{else} + +{/if} {get_combined_scripts load='footer'} diff --git a/themes/smartpocket/template/header.tpl b/themes/smartpocket/template/header.tpl index 06248f78c..d15821a19 100644 --- a/themes/smartpocket/template/header.tpl +++ b/themes/smartpocket/template/header.tpl @@ -46,9 +46,9 @@ -
+
-
+
{$GALLERY_TITLE} diff --git a/themes/smartpocket/template/index.tpl b/themes/smartpocket/template/index.tpl index f9d319783..6793bc493 100644 --- a/themes/smartpocket/template/index.tpl +++ b/themes/smartpocket/template/index.tpl @@ -1,4 +1,4 @@ -
+
{if !empty($CATEGORIES)}{$CATEGORIES}{/if} {if !empty($THUMBNAILS)}{$THUMBNAILS}{/if}
diff --git a/themes/smartpocket/template/infos_errors.tpl b/themes/smartpocket/template/infos_errors.tpl index ce2db88d9..72ae50f18 100644 --- a/themes/smartpocket/template/infos_errors.tpl +++ b/themes/smartpocket/template/infos_errors.tpl @@ -1,19 +1,23 @@ -{if isset($errors) } -
-
    - {foreach from=$errors item=error} -
  • {$error}
  • - {/foreach} -
+{if isset($errors)} +
+

{'Error'|@translate}

+ +

{'
'|@implode:$errors}

{/if} {if not empty($infos)} -
-
    - {foreach from=$infos item=info} -
  • {$info}
  • - {/foreach} -
+
+

{'Info'|@translate}

+ +

{'
'|@implode:$infos}

-{/if} \ No newline at end of file +{/if} + +{footer_script}{literal} +$(document).ready(function () { + $('.close-button').click(function() { + $(this).parents('.ui-bar').remove(); + }); +}); +{/literal}{/footer_script} \ No newline at end of file diff --git a/themes/smartpocket/template/menubar.tpl b/themes/smartpocket/template/menubar.tpl index 49fa37e14..e4679c98e 100644 --- a/themes/smartpocket/template/menubar.tpl +++ b/themes/smartpocket/template/menubar.tpl @@ -1,6 +1,7 @@ {footer_script}{literal} diff --git a/themes/smartpocket/template/navigation_bar.tpl b/themes/smartpocket/template/navigation_bar.tpl new file mode 100644 index 000000000..2dfbbe950 --- /dev/null +++ b/themes/smartpocket/template/navigation_bar.tpl @@ -0,0 +1,14 @@ +{capture}{$navbar.pages|@end}{/capture} +
+
+{strip} + {if isset($navbar.URL_PREV)} + + {/if} + {$navbar.CURRENT_PAGE} / {$navbar.pages|@key}  + {if isset($navbar.URL_NEXT)} + + {/if} +{/strip} +
+
diff --git a/themes/smartpocket/template/profile.tpl b/themes/smartpocket/template/profile.tpl index fde414605..f4c1b8f25 100644 --- a/themes/smartpocket/template/profile.tpl +++ b/themes/smartpocket/template/profile.tpl @@ -1,4 +1,4 @@ -
{include file='infos_errors.tpl'} +
{$PROFILE_CONTENT}
diff --git a/themes/smartpocket/template/profile_content.tpl b/themes/smartpocket/template/profile_content.tpl index 6c9cb5064..2b6604fa1 100644 --- a/themes/smartpocket/template/profile_content.tpl +++ b/themes/smartpocket/template/profile_content.tpl @@ -1,4 +1,3 @@ -
@@ -29,6 +28,11 @@ {/if} {if $ALLOW_USER_CUSTOMIZATION} +
+ + +
+
{html_options name=language options=$language_options selected=$language_selection} @@ -38,7 +42,6 @@
{if $ALLOW_USER_CUSTOMIZATION} - diff --git a/themes/smartpocket/template/thumbnails.tpl b/themes/smartpocket/template/thumbnails.tpl index 5e33dd0ee..acd20af19 100644 --- a/themes/smartpocket/template/thumbnails.tpl +++ b/themes/smartpocket/template/thumbnails.tpl @@ -2,7 +2,7 @@ {combine_script id='klass' path='themes/smartpocket/js/klass.min.js'} {combine_script id='photoswipe' path='themes/smartpocket/js/code.photoswipe.jquery.min.js' require='klass,jquery.mobile'} -{define_derivative name='derivative_params_thumb' width=150 height=150 crop=true} +{define_derivative name='derivative_params_thumb' width=120 height=120 crop=true} {define_derivative name='derivative_params_full' type='large'} {footer_script}{literal} @@ -10,23 +10,34 @@ $(document).ready(function(){ var options = { jQueryMobile: true, - //allowUserZoom: false, imageScaleMethod: "fitNoUpscale" }; $(".thumbnails a").photoSwipe(options); - $(".thumbnails img").load(function() { $(this).css('border', '1px solid #3c3c3c') }); + $(document).bind('orientationchange', set_thumbnails_width); + set_thumbnails_width(); }); }(window, window.jQuery, window.Code.PhotoSwipe)); + +function set_thumbnails_width() { + nb_thumbs = Math.max(3, Math.ceil($('.thumbnails').width() / 130)); + width = Math.floor(1000000 / nb_thumbs) / 10000; + $('.thumbnails li').css('width', width+'%'); +} + {/literal}{/footer_script} -
    -{foreach from=$thumbnails item=thumbnail} +{foreach from=$thumbnails item=thumbnail}{strip} +{if isset($page_selection[$thumbnail.id])}
  • {$thumbnail.TN_ALT}
  • -{/foreach} +{else} +
  • + +
  • +{/if} +{/strip}{/foreach}
-
{/if} diff --git a/themes/smartpocket/theme.css b/themes/smartpocket/theme.css index 0595d9195..d18d94709 100644 --- a/themes/smartpocket/theme.css +++ b/themes/smartpocket/theme.css @@ -2,16 +2,22 @@ @import "photoswipe.css"; .title { margin: 10px; text-align: center; } +.title .ui-btn { margin-top: -5px; } .menubar { float: right; } .home_button { float: left; } +.pwg_footer h6 { margin: 8px; text-align:right;} + +.errors h3, .infos h3{ float:left; margin-top:8px; } +.errors div, .infos div { float:right; margin-top:4px; } +.errors p, .infos p { clear:both; font-size:85%; margin-bottom:8px; } .ui-icon-profil { background-image: url("images/profil.png"); background-color: transparent; } .ui-content { overflow: hidden; } -.ui-field-contain { padding: 5px; border: 0; } +.ui-field-contain, .ui-br { padding: 5px; border: 0 !important; } .thumbnails { list-style: none; padding: 0; margin: 0; } .thumbnails:after { clear: both; content: "."; display: block; height: 0; visibility: hidden; } -.thumbnails li { float: left; width: 33.33333333%; } +.thumbnails li { float: left; } .thumbnails li a { display: block; margin: 5px; } .thumbnails li img { display: block; width: 100%; height: auto; } diff --git a/themes/smartpocket/themeconf.inc.php b/themes/smartpocket/themeconf.inc.php index a1a841081..2dd950c7d 100644 --- a/themes/smartpocket/themeconf.inc.php +++ b/themes/smartpocket/themeconf.inc.php @@ -11,4 +11,17 @@ Author URI: http://piwigo.org $themeconf = array( 'mobile' => true, ); + +//Retrive all pictures on thumbnails page +add_event_handler('loc_index_thumbnails_selection', 'sp_select_all_thumbnails'); + +function sp_select_all_thumbnails($selection) +{ + global $page, $template; + + $template->assign('page_selection', array_flip($selection)); + + return $page['items']; +} + ?> -- cgit v1.2.3