diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php index 5a08a9d20..23e9b326e 100644 --- a/admin/include/plugins.class.php +++ b/admin/include/plugins.class.php @@ -376,6 +376,7 @@ DELETE FROM '. PLUGINS_TABLE .' } // Retrieve PEM versions + // Beta test : return last version on PEM if the current version isn't known or else return the current and the last version function get_versions_to_check($beta_test=false, $version=PHPWG_VERSION) { global $conf; diff --git a/admin/plugins_new.php b/admin/plugins_new.php index 946edc9f7..a02c2415e 100644 --- a/admin/plugins_new.php +++ b/admin/plugins_new.php @@ -82,6 +82,8 @@ $template->assign('order_options', // | start template output | // +-----------------------------------------------------------------------+ +// Beta test : show plugins of last version on PEM if the current version isn't present +// If the current version in known, give the current and last version's compatible plugins $beta_test = false; if(isset($_GET['beta-test']) && $_GET['beta-test'] == 'true') @@ -115,26 +117,40 @@ if ($plugins->get_server_plugins(true, $beta_test)) . '&pwg_token='.get_pwg_token() ; + // get the age of the last revision in days $last_revision_diff = date_diff(date_create($plugin['revision_date']), date_create()); $certification = 1; + $has_compatible_version = false; - if (get_branch_from_version($plugin['compatible_with_versions'][0]) !== get_branch_from_version(PHPWG_VERSION)) - { + // Check if the current version is in the compatible version (not necessary if we are in beta test) + if ($beta_test) { + foreach ($plugin['compatible_with_versions'] as $vers) { + if (get_branch_from_version($vers) == get_branch_from_version(PHPWG_VERSION)) + { + $has_compatible_version = true; + } + } + } else { + $has_compatible_version = true; + } + + if (!$has_compatible_version) { $certification = -1; - } - elseif ($last_revision_diff->days < 90) + } + elseif ($last_revision_diff->days < 90) // if the last revision is new of 3 month or less { $certification = 3; } - elseif ($last_revision_diff->days < 180) + elseif ($last_revision_diff->days < 180) // 6 month or less { $certification = 2; } - elseif ($last_revision_diff->y > 3) + elseif ($last_revision_diff->y > 3) // 3 years or less { $certification = 0; } + // Between 6 month and 3 years : certification = 1 $template->append('plugins', array( 'ID' => $plugin['extension_id'], @@ -144,6 +160,7 @@ if ($plugins->get_server_plugins(true, $beta_test)) 'BIG_DESC' => $ext_desc, 'VERSION' => $plugin['revision_name'], 'REVISION_DATE' => preg_replace('/[^0-9]/', '', strtotime($plugin['revision_date'])), + 'REVISION_FORMATED_DATE' => format_date($plugin['revision_date'], array('day','month','year')), 'AUTHOR' => $plugin['author_name'], 'DOWNLOADS' => $plugin['extension_nb_downloads'], 'URL_INSTALL' => $url_auto_install, diff --git a/admin/themes/clear/theme.css b/admin/themes/clear/theme.css index 1a07705aa..6d2ed58c8 100644 --- a/admin/themes/clear/theme.css +++ b/admin/themes/clear/theme.css @@ -457,6 +457,10 @@ label>p.group_select { background-color: white; } +.slider::after { + color: white; +} + input:checked + .slider { background-color: #ffa646; } diff --git a/admin/themes/default/js/plugins_new.js b/admin/themes/default/js/plugins_new.js index a82f6f5de..770b096e5 100644 --- a/admin/themes/default/js/plugins_new.js +++ b/admin/themes/default/js/plugins_new.js @@ -1,3 +1,4 @@ +// <-- Define sort orders --> var sortOrder = 'date'; var sortPlugins = (function (a, b) { if (sortOrder == 'downloads' || sortOrder == 'revision' || sortOrder == 'date') @@ -10,9 +11,14 @@ var sortPlugins = (function (a, b) { $(function () { + // <-- Set the advanced filters --> + let betaTestPlugins = $('#showBetaTestPlugin')[0].hasAttribute('checked'); + + // object that remember filters states (initialized later) let filters = {}; + // toggle advanced filter's panel $(".advanced-filter-btn").click(advanced_filter_button_click); $(".advanced-filter span.icon-cancel").click(advanced_filter_hide); @@ -68,9 +74,11 @@ $(function () { displayStars(ratingContainer.find('.rating-star-container'), rating); }) - let authorNames = [{ value: '', text: str_all }]; - let tagsNames = [{ value: '', text: str_all }] - + // put default values in the select + let authorNames = [{ value: '', text: "-" }]; + let tagsNames = [{ value: '', text: "-" }] + + // read all plugin boxes to get author and tags $('.pluginBox').each((i,el) => { let author = $(el).data('author'); author.split(', ').forEach(name => { @@ -136,6 +144,7 @@ $(function () { } }); + // All the slider values and it's corresponding month's number and label function value_to_month(val) { switch (val) { case 6: @@ -157,11 +166,12 @@ $(function () { return [60, str_x_years.replace('%d', 5)]; break; default: - return [240, str_x_years.replace('%d', 20)]; + return [Number.MAX_SAFE_INTEGER, str_from_begining]; break; } } + // The certification filter dosen't include incompatible if the beta-test option is not checked let minCertification = betaTestPlugins ? -1 : 0; $('.certification-filter-slider').slider({ @@ -175,6 +185,7 @@ $(function () { } }); + // Diffrence between two dates, in months function monthDiff(d1, d2) { var months; months = (d2.getFullYear() - d1.getFullYear()) * 12; @@ -206,6 +217,8 @@ $(function () { } } + // Updates labels when input change + function updateRatingFilterLabel(value) { displayStars($('.advanced-filter-rating .rating-star-container'), value); } @@ -227,6 +240,10 @@ $(function () { $('.revision-date').html(label); } + + // <-- Apply advanced filters --> + + // object that remember filters states filters = { "search": $('#search').val(), "author": '', @@ -285,6 +302,9 @@ $(function () { }) $('#showBetaTestPlugin').on('change', (e) => { + + $('.beta-test-plugin-switch .slider').addClass('loading'); + let queryParams = new URLSearchParams(window.location.search); queryParams.set("beta-test", e.currentTarget.checked.toString()); diff --git a/admin/themes/default/template/plugins_new.tpl b/admin/themes/default/template/plugins_new.tpl index ed89ec40f..ee7236f45 100644 --- a/admin/themes/default/template/plugins_new.tpl +++ b/admin/themes/default/template/plugins_new.tpl @@ -14,21 +14,21 @@ {combine_css path="admin/themes/default/css/components/general.css"} {footer_script} -const str_confirm_msg = '{"Yes, I am sure"|@translate}'; -const str_cancel_msg = "{"No, I have changed my mind"|@translate}"; -const str_install_title = '{'Are you sure you want to install the plugin "%s"?'|@translate|@escape:'javascript'}'; +const str_confirm_msg = "{"Yes, I am sure"|@translate}"; +const str_cancel_msg = "{"No, I have chaged my mind"|@translate}"; +const str_install_title = "{'Are you sure you want to install the plugin "%s"?'|@translate|@escape:'javascript'}"; const strs_certification = { - "-1" : '{'This plugin is incompatible with your version'|@translate}', - "0" : '{'This plugin have no update since 3 years ! It may be outdated'|@translate}', - "1" : '{'This plugin has no recent update'|@translate}', - "2" : '{'This plugin was updated less than 6 months ago'|@translate}', - "3" : '{'This plugin have been updated recently'|@translate}', + "-1" : "{'This plugin is incompatible with your version'|@translate}", + "0" : "{'This plugin have no update since 3 years ! It may be outdated'|@translate}", + "1" : "{'This plugin has no recent update'|@translate}", + "2" : "{'This plugin was updated less than 6 months ago'|@translate}", + "3" : "{'This plugin have been updated recently'|@translate}", }; -const str_all = '{"All of them"|@translate}' -const str_x_month = '{"%d month"|@translate}'; -const str_x_months = '{"%d months"|@translate}'; -const str_x_year = '{"%d year"|@translate}'; -const str_x_years = '{"%d years"|@translate}'; +const str_x_month = "{"%d month"|@translate}"; +const str_x_months = "{"%d months"|@translate}"; +const str_x_year = "{"%d year"|@translate}"; +const str_x_years = "{"%d years"|@translate}"; +const str_from_begining = "{"since the beginning"|@translate}"; {/footer_script}