From bf3beb9bdd3841c21f37106fc946da2300c4132c Mon Sep 17 00:00:00 2001 From: HWFord <54360213+HWFord@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:35:27 +0100 Subject: [PATCH] fixes #2268 add whats new popin set popin display in user pref, if user closes don't display again keep bell notification displayed for 30 days so user can reopen modal for next version add user pref to install Add css for template when close popin call api method to update user pref to hide popin --- admin.php | 61 +++++++++++ admin/themes/clear/theme.css | 21 ++++ admin/themes/default/template/footer.tpl | 71 +++++++++++- admin/themes/default/theme.css | 132 ++++++++++++++++++++++- admin/themes/roma/theme.css | 21 ++++ include/common.inc.php | 8 ++ install.php | 6 +- 7 files changed, 317 insertions(+), 3 deletions(-) diff --git a/admin.php b/admin.php index 0c552e376..218afcc4d 100644 --- a/admin.php +++ b/admin.php @@ -338,6 +338,66 @@ if ( invalidate_user_cache(); } +$show_whats_new = false; + +$whats_new_major_version = get_branch_from_version(PHPWG_VERSION); + +if (userprefs_get_param('show_whats_new_'.$whats_new_major_version, true) and pwg_is_dbconf_writeable()) +{ + if ($user['registration_date'] > $conf['last_major_update']) + { + userprefs_update_param('show_whats_new_'.$whats_new_major_version, false); + } + else + { + // purge old whats_new_* + if (isset($user['preferences'])) + { + $userprefs_params_to_delete = array(); + + foreach (array_keys($user['preferences']) as $pref_param) + { + if (preg_match('/^whats_new_/', $pref_param)) + { + $userprefs_params_to_delete[] = $pref_param; + } + } + + if (count($userprefs_params_to_delete) > 0) + { + userprefs_delete_param($userprefs_params_to_delete); + } + } + + $show_whats_new = true; + } +} + +$release_note_url = PHPWG_URL.'/releases/'.$whats_new_major_version.'.0.0'; + +$whats_new_imgs = array( + '1' =>'https://ressources.piwigo.com/uploads/c/v/7/cv7jpz6hf8//2024/11/07/20241107171642-58ded6af.png', + '2' =>'https://ressources.piwigo.com/uploads/c/v/7/cv7jpz6hf8//2024/11/07/20241107171642-9d651969.png', + '3' =>'https://ressources.piwigo.com/uploads/c/v/7/cv7jpz6hf8//2024/11/07/20241107171643-d659d017.png', + '4' =>'https://ressources.piwigo.com/uploads/c/v/7/cv7jpz6hf8//2024/11/07/20241107171642-1109101f.png', +); + +$display_bell = false; +if (strtotime($conf['last_major_update']) > strtotime('1 month ago')) +{ + $display_bell = true; +} + +$template->assign( + array( + 'SHOW_WHATS_NEW' => $show_whats_new, + 'WHATS_NEW_MAJOR_VERSION' => $whats_new_major_version, + 'RELEASE_NOTE_URL' => $release_note_url, + 'WHATS_NEW_IMGS' => $whats_new_imgs, + 'DISPLAY_BELL' => $display_bell, + ) +); + // +-----------------------------------------------------------------------+ // | Include specific page | // +-----------------------------------------------------------------------+ @@ -363,4 +423,5 @@ flush_page_messages(); $template->pparse('admin'); include(PHPWG_ROOT_PATH.'include/page_tail.php'); + ?> diff --git a/admin/themes/clear/theme.css b/admin/themes/clear/theme.css index 8b165194d..bdf80b83f 100644 --- a/admin/themes/clear/theme.css +++ b/admin/themes/clear/theme.css @@ -863,4 +863,25 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important; .cat-move-order-popin input[name=recursiveAutoOrder]:hover { background-color: #ffc17e; +} + +#whats_new_popin{ + background-color: white; +} + +.close_whats_new{ + color:white +} + +#whats_new h3{ + color: #3C3C3C; +} + +#whats_new button{ + background-color: #ECECEC; + color: #3C3C3C; +} + +#whats_new button:hover{ + background-color:#FFA646; } \ No newline at end of file diff --git a/admin/themes/default/template/footer.tpl b/admin/themes/default/template/footer.tpl index bf425aada..a6fbd163f 100644 --- a/admin/themes/default/template/footer.tpl +++ b/admin/themes/default/template/footer.tpl @@ -17,7 +17,14 @@ {/if} {* *} +
+
+ +

{'What\'s new in version %s'|translate:$WHATS_NEW_MAJOR_VERSION}

+
+
+
+

{'A new interface for user management'|translate}

+ +
+
+

{'Brand new features : Activities logs and PDF reader'|translate}

+ +
+
+
+
+

{'Enhanced interface for batch manager and album selector'|translate}

+ +
+
+

{'Even more filters for the gallery search engine'|translate}

+ +
+
+
+
+ + {'Read the release note'|translate} +
+
+
+ + + {combine_script id='jquery.tipTip' load='footer' path='themes/default/js/plugins/jquery.tipTip.minified.js'} {footer_script require='jquery.tipTip'} @@ -43,6 +88,30 @@ jQuery('a.externalLink').click(function() { window.open(jQuery(this).attr("href")); return false; }); + +function hide_user_whats_new() { + $.ajax({ + url: "ws.php?format=json&method=pwg.users.preferences.set", + type: "POST", + dataType: "JSON", + data: { + param: 'show_whats_new_{$WHATS_NEW_MAJOR_VERSION}', + value: false, + } + }) + $('#whats_new').hide(); +} + +function show_user_whats_new() { + $('#whats_new').show(); +} + +{if isset($SHOW_WHATS_NEW) && $SHOW_WHATS_NEW} + show_user_whats_new() +{/if} + + + {/footer_script} diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css index cb797bed8..62dfb3af9 100644 --- a/admin/themes/default/theme.css +++ b/admin/themes/default/theme.css @@ -7555,4 +7555,134 @@ color:#FF7B00; .promote-content .left-side img { width: 100px; } -} \ No newline at end of file +} + +/* Css for whats new popin */ +#whats_new{ + display: none; + position: fixed; + z-index: 100; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.7); +} + +#whats_new_popin{ + width: 40%; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + text-align: left; + padding: 30px; + border-radius: 10px; + max-height:90%; +} + +.close_whats_new{ + position: absolute; + right: -40px; + top: -40px; + font-size: 30px; + transition: all 125ms ease-out; +} + +#whats_new h3{ + font-size: 19px; + font-weight: 700; + line-height: 25.87px; + text-align: center; + background-color:transparent; + margin-top:0px; +} + +#whats_new h4{ + font-size: 15px; + font-weight: 700; + line-height: 20.43px; + text-align: left; + margin:0; + margin-bottom:15px; +} + +#whats_new .whats_new_block_container{ + display:flex; +} + +#whats_new .whats_new_block{ + border-radius:13px; + padding:15px; + padding-bottom:0px; + display:flex; + flex-direction:column; + justify-content:space-between; + margin:7px; +} + +#whats_new .whats_new_block:hover{ + scale:115%; + transition:.6s; +} + +#whats_new .whats_new_block.icon-yellow:hover{ + transform-origin: top left; +} + +#whats_new .whats_new_block.icon-green:hover{ + transform-origin: top right; +} + +#whats_new .whats_new_block.icon-blue:hover{ + transform-origin: bottom left; +} + +#whats_new .whats_new_block.icon-purple:hover{ + transform-origin: bottom right; +} + +#whats_new .whats_new_block.icon-yellow, +#whats_new .whats_new_block.icon-purple{ + width:40%; +} + +#whats_new .whats_new_block.icon-green, +.whats_new_block.icon-blue{ + width:60%; +} + + +#whats_new .whats_new_block img{ + width:100%; + height:auto; +} + +#whats_new .whats_new_buttons{ + display:flex; + margin-top:15px; + justify-content:space-between; +} + +#whats_new button{ + padding: 9px 10px; + font-size: 12px; + font-style: normal; + font-weight: 700; + line-height: normal; + border:none; + cursor:pointer; + transition: all 125ms ease-out; +} + +#whats_new_notification{ + border-radius: 15px; + top: 2px; + position: absolute; + right: 42px; + padding: 1px; + cursor: pointer; + box-shadow: 0px 4px 4px 0px #00000040; + font-size: 10px; +} diff --git a/admin/themes/roma/theme.css b/admin/themes/roma/theme.css index f2b632eea..ee4788e92 100644 --- a/admin/themes/roma/theme.css +++ b/admin/themes/roma/theme.css @@ -2306,4 +2306,25 @@ ul.jqtree-tree li.jqtree-ghost span.jqtree-line { .first-letter-capitalize::first-letter { text-transform: uppercase; +} + +#whats_new_popin{ + background-color: #3C3C3C; +} + +.close_whats_new{ + color:#3C3C3C; +} + +#whats_new h3{ + color: #CCCCCC; +} + +#whats_new button{ + background-color:#2E2E2E; + color:#777777; +} + +#whats_new button:hover{ + background-color:#1B1B1B; } \ No newline at end of file diff --git a/include/common.inc.php b/include/common.inc.php index 3b63cdf04..37ce01220 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -166,6 +166,12 @@ elseif ($conf['piwigo_installed_version'] != PHPWG_VERSION) conf_update_param('piwigo_installed_version', PHPWG_VERSION); } +if (!isset($conf['last_major_update'])) +{ + list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); + conf_update_param('last_major_update', $dbnow, true); +} + // 2022-02-25 due to escape on "rank" (becoming a mysql keyword in version 8), the $conf['order_by'] might // use a "rank", even if admin/configuration.php should have removed it. We must remove it. // TODO remove this data update as soon as 2025 arrives @@ -222,6 +228,8 @@ load_language('common.lang'); if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) ) { load_language('admin.lang'); + // Add language for temporary strings for new popup, from piwigo 15 + load_language('whats_new_'.get_branch_from_version(PHPWG_VERSION).'.lang'); } trigger_notify('loading_lang'); load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); diff --git a/install.php b/install.php index e5d278d04..4f538373c 100644 --- a/install.php +++ b/install.php @@ -486,6 +486,8 @@ else $user = build_user(1, true); log_user($user['id'], false); + + $user['preferences']['show_whats_new_'.get_branch(PHPWG_VERSION)] = false; // newsletter subscription if ($is_newsletter_subscribe) @@ -497,9 +499,11 @@ else array('origin' => 'installation') ); - userprefs_update_param('show_newsletter_subscription', false); + $user['preferences']['show_newsletter_subscription'] = false; } + userprefs_save(); + // email notification if (isset($_POST['send_credentials_by_mail'])) {