From 692650da3e0df2e4c2092ad89981906c90b38884 Mon Sep 17 00:00:00 2001 From: lenovo Date: Fri, 11 Nov 2022 12:12:50 +0100 Subject: [PATCH] moved filters div in php + small changes in docker version --- srcs/plugins/map_prof/map_prof_hooks.php | 32 +------ srcs/plugins/map_prof/mp_create_div.php | 38 ++++++++ srcs/plugins/map_prof/mp_get_filters.php | 2 +- .../map_prof/scripts/mp_create_filters.js | 1 + srcs/plugins/map_prof/scripts/mp_init_map.js | 2 +- .../wordpress/conf/wp_entrypoint.sh | 92 +++++++++++++------ 6 files changed, 106 insertions(+), 61 deletions(-) create mode 100644 srcs/plugins/map_prof/mp_create_div.php diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index 089f81f..f699b04 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -29,6 +29,7 @@ require_once(dirname(__FILE__) . '/mp_get_events.php'); require_once(dirname(__FILE__) . '/mp_sort_events.php'); require_once(dirname(__FILE__) . '/mp_get_filters.php'); require_once(dirname(__FILE__) . '/mp_address_errors.php'); +require_once(dirname(__FILE__) . '/mp_create_div.php'); @@ -93,36 +94,9 @@ function mp_ljdp_map() { * ADD FILTERS */ - /* - pays - ville - categorie - */ -// $filters = (object)[]; -// $filters->pays = []; -// $filters->ville = []; -// $filters->categorie = []; -// -// mp_console_log("filters:"); -// mp_console_log($filters); + $mp_map_div = mp_create_div($filters); - - $mp_api_script = ' -
-
- '; -// foreach ($pays as $loc) { -// $mp_api_script .= '

'; -// $mp_api_script .= $loc; -// $mp_api_script .= '

'; -// } - $mp_api_script .= ' -
-
-
- '; - - return $mp_api_script; + return $mp_map_div; } add_shortcode('lejourduprof_map', 'mp_ljdp_map'); diff --git a/srcs/plugins/map_prof/mp_create_div.php b/srcs/plugins/map_prof/mp_create_div.php new file mode 100644 index 0000000..9260d4f --- /dev/null +++ b/srcs/plugins/map_prof/mp_create_div.php @@ -0,0 +1,38 @@ + +
+ '; + + foreach ($filters as $key => $filter) { + $mp_map_div .= ' +
+
+

'.$key.'

+
+
+

TOUT DESELECTIONNER

+ '; + foreach ($filter as $value) { + $mp_map_div .= ' +

'.$value->_name.'

+ '; + } + $mp_map_div .= ' +
+
+ '; + }; + + $mp_map_div .= ' +
+
+ + '; + + return $mp_map_div; +} + +?> diff --git a/srcs/plugins/map_prof/mp_get_filters.php b/srcs/plugins/map_prof/mp_get_filters.php index ff85500..9130221 100644 --- a/srcs/plugins/map_prof/mp_get_filters.php +++ b/srcs/plugins/map_prof/mp_get_filters.php @@ -69,7 +69,7 @@ function mp_get_filters($events) { } foreach ($filters as $key => $value) { - usort($filters->$key, mp_filter_compare); + usort($filters->$key, 'mp_filter_compare'); } return $filters; diff --git a/srcs/plugins/map_prof/scripts/mp_create_filters.js b/srcs/plugins/map_prof/scripts/mp_create_filters.js index 1741877..fc7ad8e 100644 --- a/srcs/plugins/map_prof/scripts/mp_create_filters.js +++ b/srcs/plugins/map_prof/scripts/mp_create_filters.js @@ -37,6 +37,7 @@ function fill_filters(filters_div) { */ let content = ""; + // use Object.keys to obtain an array of object keys let keys = Object.keys(filters); keys.forEach((key) => { diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js index a75d568..1cb602a 100644 --- a/srcs/plugins/map_prof/scripts/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -92,7 +92,7 @@ function mp_init_map() { draw_clusters(map, markers); let filters_div = document.getElementById("ljdp_map_filters"); - fill_filters(filters_div); + //fill_filters(filters_div); // add listener to close infowindow at any click on map map.addListener('click', function() { diff --git a/srcs/requirements/wordpress/conf/wp_entrypoint.sh b/srcs/requirements/wordpress/conf/wp_entrypoint.sh index 88275b0..7dc1e73 100644 --- a/srcs/requirements/wordpress/conf/wp_entrypoint.sh +++ b/srcs/requirements/wordpress/conf/wp_entrypoint.sh @@ -12,6 +12,7 @@ RESET="\e[0m" # install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/ # commands : https://developer.wordpress.org/cli/commands/ + echo -e ${YELLOW}download wordpress :${RESET} if ! wp core version --path="${WP_VOLUME_DIR}" 2> /dev/null then @@ -21,9 +22,59 @@ else echo -e ${GREEN}already there !${RESET} fi -# create config file : -echo -e ${YELLOW}config wordpress :${RESET} -if ! wp config path --path="${WP_VOLUME_DIR}" --quiet 2> /dev/null +# # create config file : +# echo -e ${YELLOW}config wordpress :${RESET} +# if ! wp config path --path="${WP_VOLUME_DIR}" --quiet 2> /dev/null +# then +# wp config create \ +# --dbhost="${DB_HOST}" \ +# --dbname="${DB_NAME}" \ +# --dbuser="${DB_USER}" \ +# --dbpass="${DB_PSWD}" \ +# --path="${WP_VOLUME_DIR}" --allow-root +# else +# echo -e ${GREEN}already configured !${RESET} +# fi +# +# # install wordpress : +# echo -e ${YELLOW}install wordpress :${RESET} +# if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null +# then +# wp core install \ +# --url="${WP_URL}" \ +# --title="${WP_TITLE}" \ +# --admin_user="${WP_ADMIN}" \ +# --admin_email="${WP_ADMIN_EMAIL}" \ +# --admin_password="${WP_ADMIN_PSWD}" \ +# --skip-email \ +# --path="${WP_VOLUME_DIR}" --allow-root +# else +# echo -e ${GREEN}already installed !${RESET} +# fi +# +# # create user : +# echo -e ${YELLOW}create wordpress user :${RESET} +# if ! wp user get ${WP_USER} --path="${WP_VOLUME_DIR}" --field=login 2> /dev/null +# then +# wp user create \ +# "${WP_USER}" "${WP_USER_EMAIL}" \ +# --user_pass="${WP_USER_PSWD}" \ +# --path="${WP_VOLUME_DIR}" --allow-root +# else +# echo -e ${GREEN}already created !${RESET} +# fi +# +# # change owner and permissions to wp files +# chown -R www-data:www-data /var/www/* +# chmod 755 -R /var/www/* +# +# # symlinks for folders found in host plugins/ +# plugins=$(ls ${WP_VOLUME_PLUGINS}) +# for dir in $plugins; do +# ln -s ${WP_VOLUME_PLUGINS}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir +# done + +if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null then wp config create \ --dbhost="${DB_HOST}" \ @@ -31,14 +82,6 @@ then --dbuser="${DB_USER}" \ --dbpass="${DB_PSWD}" \ --path="${WP_VOLUME_DIR}" --allow-root -else - echo -e ${GREEN}already configured !${RESET} -fi - -# install wordpress : -echo -e ${YELLOW}install wordpress :${RESET} -if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null -then wp core install \ --url="${WP_URL}" \ --title="${WP_TITLE}" \ @@ -47,31 +90,20 @@ then --admin_password="${WP_ADMIN_PSWD}" \ --skip-email \ --path="${WP_VOLUME_DIR}" --allow-root -else - echo -e ${GREEN}already installed !${RESET} -fi - -# create user : -echo -e ${YELLOW}create wordpress user :${RESET} -if ! wp user get ${WP_USER} --path="${WP_VOLUME_DIR}" --field=login 2> /dev/null -then wp user create \ "${WP_USER}" "${WP_USER_EMAIL}" \ --user_pass="${WP_USER_PSWD}" \ --path="${WP_VOLUME_DIR}" --allow-root -else - echo -e ${GREEN}already created !${RESET} + + chown -R www-data:www-data /var/www/* + chmod 755 -R /var/www/* + + plugins=$(ls ${WP_VOLUME_PLUGINS}) + for dir in $plugins; do + ln -s ${WP_VOLUME_PLUGINS}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir + done fi -# change owner and permissions to wp files -chown -R www-data:www-data /var/www/* -chmod 755 -R /var/www/* - -# symlinks for folders found in host plugins/ -plugins=$(ls ${WP_VOLUME_PLUGINS}) -for dir in $plugins; do - ln -s ${WP_VOLUME_PLUGINS}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir -done exec "${PHP_VERSION}" -FR