From b232bb8d45260cb733f6a6618b45df3d3ebaec85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Nov 2024 14:21:52 +0100 Subject: [PATCH] Debug v21 --- htdocs/admin/modules.php | 33 ++++---- .../{dolistore => remotestore}/ajax/image.php | 4 +- .../class/PSWebServiceLibrary.class.php | 0 .../class/PS_WS_LIB-LICENSE.md | 1 - .../class/README.md | 3 +- .../class/dolistore.class.php | 74 +++++++++++++----- .../css/store.css} | 13 ++- .../img/Download-128.png | Bin .../img/NoImageAvailable.png | Bin .../img/compatible.png | Bin .../img/dolistore.png | Bin .../{dolistore => remotestore}/img/follow.png | Bin .../img/object_dolistore.png | Bin htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/website.lang | 2 +- 15 files changed, 91 insertions(+), 40 deletions(-) rename htdocs/admin/{dolistore => remotestore}/ajax/image.php (94%) rename htdocs/admin/{dolistore => remotestore}/class/PSWebServiceLibrary.class.php (100%) rename htdocs/admin/{dolistore => remotestore}/class/PS_WS_LIB-LICENSE.md (99%) rename htdocs/admin/{dolistore => remotestore}/class/README.md (84%) rename htdocs/admin/{dolistore => remotestore}/class/dolistore.class.php (84%) rename htdocs/admin/{dolistore/css/dolistore.css => remotestore/css/store.css} (96%) rename htdocs/admin/{dolistore => remotestore}/img/Download-128.png (100%) rename htdocs/admin/{dolistore => remotestore}/img/NoImageAvailable.png (100%) rename htdocs/admin/{dolistore => remotestore}/img/compatible.png (100%) rename htdocs/admin/{dolistore => remotestore}/img/dolistore.png (100%) rename htdocs/admin/{dolistore => remotestore}/img/follow.png (100%) rename htdocs/admin/{dolistore => remotestore}/img/object_dolistore.png (100%) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 08c231de866..9e91aac4327 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; +require_once DOL_DOCUMENT_ROOT.'/admin/remotestore/class/dolistore.class.php'; ' @phan-var-force string $dolibarr_main_url_root_alt @@ -79,14 +79,15 @@ $search_nature = GETPOST('search_nature', 'alpha'); $search_version = GETPOST('search_version', 'alpha'); -// For dolistore search +// For remotestore search $options = array(); -$options['per_page'] = 20; +$options['per_page'] = 10; $options['categorie'] = ((int) (GETPOSTINT('categorie') ? GETPOSTINT('categorie') : 0)); $options['start'] = ((int) (GETPOSTINT('start') ? GETPOSTINT('start') : 0)); $options['end'] = ((int) (GETPOSTINT('end') ? GETPOSTINT('end') : 0)); $options['search'] = GETPOST('search_keyword', 'alpha'); -$dolistore = new Dolistore(false); + +$remotestore = new Dolistore(false); if (!$user->admin) { @@ -473,7 +474,7 @@ if ($action == 'set' && $user->admin) { $form = new Form($db); $morejs = array(); -$morecss = array("/admin/dolistore/css/dolistore.css"); +$morecss = array("/admin/remotestore/css/store.css"); // Set dir where external modules are installed if (!dol_is_dir($dirins)) { @@ -1270,18 +1271,21 @@ if ($mode == 'marketplace') { if (!getDolGlobalString('MAIN_DISABLE_DOLISTORE_SEARCH') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) { // $options is array with filter criteria - //var_dump($options); - $dolistore->getRemoteCategories(); - $dolistore->getRemoteProducts($options); + + $nbmaxtoshow = $options['per_page']; + $options['per_page']++; + + $remotestore->getRemoteCategories(); + $remotestore->getRemoteProducts($options); print ''.$langs->trans('DOLISTOREdescriptionLong').'

'; - $previouslink = $dolistore->get_previous_link(); - $nextlink = $dolistore->get_next_link(); + $previouslink = $remotestore->get_previous_link(); + $nextlink = $remotestore->get_next_link(); print '
'; - print '
'; ?> + print ''; ?>
@@ -1289,7 +1293,7 @@ if ($mode == 'marketplace') {
@@ -1305,13 +1309,14 @@ if ($mode == 'marketplace') {
    get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?> + echo $remotestore->get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?>
+
- get_products(); ?> + get_products($nbmaxtoshow); ?>
diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/remotestore/ajax/image.php similarity index 94% rename from htdocs/admin/dolistore/ajax/image.php rename to htdocs/admin/remotestore/ajax/image.php index e5896a4eec1..c32791685fa 100644 --- a/htdocs/admin/dolistore/ajax/image.php +++ b/htdocs/admin/remotestore/ajax/image.php @@ -23,13 +23,13 @@ if (!defined('NOTOKENRENEWAL')) { /** - * \file htdocs/admin/dolistore/ajax/image.php + * \file htdocs/admin/remotestore/ajax/image.php * \ingroup admin * \brief Page des information dolistore */ require "../../../main.inc.php"; -require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; +require_once DOL_DOCUMENT_ROOT.'/admin/remotestore/class/dolistore.class.php'; /* diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/remotestore/class/PSWebServiceLibrary.class.php similarity index 100% rename from htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php rename to htdocs/admin/remotestore/class/PSWebServiceLibrary.class.php diff --git a/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md b/htdocs/admin/remotestore/class/PS_WS_LIB-LICENSE.md similarity index 99% rename from htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md rename to htdocs/admin/remotestore/class/PS_WS_LIB-LICENSE.md index 0dbd9d23112..6a4a4887584 100644 --- a/htdocs/admin/dolistore/class/PS_WS_LIB-LICENSE.md +++ b/htdocs/admin/remotestore/class/PS_WS_LIB-LICENSE.md @@ -50,4 +50,3 @@ e) to display the Original Work publicly. [0]: http://rosenlaw.com/OSL3.0-explained.htm - diff --git a/htdocs/admin/dolistore/class/README.md b/htdocs/admin/remotestore/class/README.md similarity index 84% rename from htdocs/admin/dolistore/class/README.md rename to htdocs/admin/remotestore/class/README.md index c4c8110e732..623f999d766 100644 --- a/htdocs/admin/dolistore/class/README.md +++ b/htdocs/admin/remotestore/class/README.md @@ -12,5 +12,4 @@ https://www.gnu.org/licenses/license-list.html#OSL ## Local changes - Change `executeRequest` to public method because - `htdocs/admin/dolistore/ajax/image.php#` uses it. - + `htdocs/admin/remotestore/ajax/image.php#` uses it. diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/remotestore/class/dolistore.class.php similarity index 84% rename from htdocs/admin/dolistore/class/dolistore.class.php rename to htdocs/admin/remotestore/class/dolistore.class.php index a3648c44a68..0829405eb85 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/remotestore/class/dolistore.class.php @@ -19,7 +19,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; if (!class_exists('PrestaShopWebservice')) { // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors. - include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; + include_once DOL_DOCUMENT_ROOT.'/admin/remotestore/class/PSWebServiceLibrary.class.php'; } @@ -254,16 +254,25 @@ class Dolistore $nbofcateg = count($this->categories); for ($i = 0; $i < $nbofcateg; $i++) { $cat = $this->categories[$i]; + + if ((string) $cat->name->language[$this->lang - 1] == 'Goodies') { + continue; + } + if ($cat->is_root_category == 1 && $parent == 0) { - $html .= '
  • description->language[$this->lang - 1])).'">'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' '.dol_escape_htmltag($cat->nb_products_recursive).'

    '; + $html .= '
  • description->language[$this->lang - 1])).'">'; + //$html .= dol_escape_htmltag($cat->name->language[$this->lang - 1]); + $html .= 'DoliStore'; + $html .= '  ('.dol_escape_htmltag($cat->nb_products_recursive).')

    '; $html .= self::get_categories((int) $cat->id); $html .= "
  • \n"; } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau $select = ($cat->id == $this->categorie) ? ' selected' : ''; $html .= '
  • description->language[$this->lang - 1])).'" '; - $html .= '>'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' '.dol_escape_htmltag($cat->nb_products_recursive).''; + $html .= '>'.dol_escape_htmltag($cat->name->language[$this->lang - 1]); + $html .= '  ('.dol_escape_htmltag($cat->nb_products_recursive).')'; $html .= self::get_categories((int) $cat->id); $html .= "
  • \n"; } @@ -283,15 +292,24 @@ class Dolistore /** * Return list of product formatted for output * - * @return string HTML output + * @param int $nbmaxtoshow Nb max of product to show + * @return string HTML output */ - public function get_products() + public function get_products($nbmaxtoshow = 10) { // phpcs:enable - global $langs, $conf; + global $langs; + $html = ""; - $last_month = time() - (30 * 24 * 60 * 60); + $last_month = dol_now() - (30 * 24 * 60 * 60); + + $i = 0; foreach ($this->products as $product) { + $i++; + if ($i > $nbmaxtoshow) { + break; + } + // check new product ? $newapp = ''; if ($last_month < strtotime($product->date_add)) { @@ -305,11 +323,11 @@ class Dolistore // add image or default ? if ($product->id_default_image != '') { - $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.urlencode((string) (((int) $product->id))).'&id_image='.urlencode((string) (((int) $product->id_default_image))); + $image_url = DOL_URL_ROOT.'/admin/remotestore/ajax/image.php?id_product='.urlencode((string) (((int) $product->id))).'&id_image='.urlencode((string) (((int) $product->id_default_image))); $images = ''; - $images .= ''; + $images .= ''; } else { - $images = ''; + $images = ''; } // free or pay ? @@ -318,8 +336,8 @@ class Dolistore $download_link = ''; } else { $price = '

    '.$langs->trans('Free').'

    '; - $download_link = ''; - $download_link .= '

    '; + $download_link = ''; + $download_link .= ''; } // Set and check version @@ -357,22 +375,42 @@ class Dolistore //output template $html .= ''; - $html .= '
    '; + $html .= '
    '; $html .= $newapp.$images; // No dol_escape_htmltag, it is already escape html $html .= '
    '; $html .= '

    '; - $html .= dol_escape_htmltag($product->name->language[$this->lang - 1]); + $html .= dol_escape_htmltag(dol_string_nohtmltag($product->name->language[$this->lang - 1])); $html .= '
    '; $html .= $version; // No dol_escape_htmltag, it is already escape html $html .= '

    '; - $html .= ' '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.dol_escape_htmltag($product->reference).' - '.dol_escape_htmltag($langs->trans('Id')).': '.((int) $product->id).'

    '.dol_escape_htmltag($product->description_short->language[$this->lang - 1]).''; + $html .= ' '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.dol_escape_htmltag($product->reference).' - '.dol_escape_htmltag($langs->trans('Id')).': '.((int) $product->id).'
    '; + $html .= '
    '.dol_escape_htmltag(dol_string_nohtmltag($product->description_short->language[$this->lang - 1])); + $html.= ''; // do not load if display none - $html .= ''; + $html .= ''; $html .= $price; $html .= ''; - $html .= ''.$download_link.''; + $html .= ''.$download_link.''; $html .= ''; } + + if (empty($this->products)) { + $html .= ''; + $html .= '

    '; + $langs->load("website"); + $html .= $langs->trans("noResultsWereFound").'...'; + $html .= '

    '; + $html .= ''; + } + + if (count($this->products) > $nbmaxtoshow) { + $html .= ''; + $html .= '

    '; + $html .= $langs->trans("ThereIsMoreThanXAnswers", $nbmaxtoshow).'...'; + $html .= '

    '; + $html .= ''; + } + return $html; } diff --git a/htdocs/admin/dolistore/css/dolistore.css b/htdocs/admin/remotestore/css/store.css similarity index 96% rename from htdocs/admin/dolistore/css/dolistore.css rename to htdocs/admin/remotestore/css/store.css index c3a8b6ca7ce..8e0a9a87caa 100644 --- a/htdocs/admin/dolistore/css/dolistore.css +++ b/htdocs/admin/remotestore/css/store.css @@ -1,4 +1,13 @@ +table#list_of_modules { + border-spacing: 0px; +} +.imgstore { + max-height:150px; + max-width: 150px; + box-shadow: 5px 5px 20px #ddd; +} + div.divsearchfield { margin: 4px 12px 4px 2px; padding-left: 2px; @@ -109,7 +118,7 @@ div.divsearchfield { padding-left: 35px; } tr.app { - height:250px; + height: 200px; } tr.app td { border-bottom: 1px solid #888; @@ -230,4 +239,4 @@ span.details{ font-size: 12px; margin-left: 10px; vertical-align: super; -} \ No newline at end of file +} diff --git a/htdocs/admin/dolistore/img/Download-128.png b/htdocs/admin/remotestore/img/Download-128.png similarity index 100% rename from htdocs/admin/dolistore/img/Download-128.png rename to htdocs/admin/remotestore/img/Download-128.png diff --git a/htdocs/admin/dolistore/img/NoImageAvailable.png b/htdocs/admin/remotestore/img/NoImageAvailable.png similarity index 100% rename from htdocs/admin/dolistore/img/NoImageAvailable.png rename to htdocs/admin/remotestore/img/NoImageAvailable.png diff --git a/htdocs/admin/dolistore/img/compatible.png b/htdocs/admin/remotestore/img/compatible.png similarity index 100% rename from htdocs/admin/dolistore/img/compatible.png rename to htdocs/admin/remotestore/img/compatible.png diff --git a/htdocs/admin/dolistore/img/dolistore.png b/htdocs/admin/remotestore/img/dolistore.png similarity index 100% rename from htdocs/admin/dolistore/img/dolistore.png rename to htdocs/admin/remotestore/img/dolistore.png diff --git a/htdocs/admin/dolistore/img/follow.png b/htdocs/admin/remotestore/img/follow.png similarity index 100% rename from htdocs/admin/dolistore/img/follow.png rename to htdocs/admin/remotestore/img/follow.png diff --git a/htdocs/admin/dolistore/img/object_dolistore.png b/htdocs/admin/remotestore/img/object_dolistore.png similarity index 100% rename from htdocs/admin/dolistore/img/object_dolistore.png rename to htdocs/admin/remotestore/img/object_dolistore.png diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9f269081b7f..8504fa7445f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2591,3 +2591,4 @@ ToolToDecryptAString=Tool to decrypt a string Decrypt=Decrypt FilesIntegrityDesc=If you want to check the integrity of files instead of database, you can do it by using this tool. AttributeCodeHelp=A code of your choice (without special char and space) to identify the property.
    Note that if an object B is created from an existing object A that has a different type (for example creation of an invoice from an order), the value of the complementary attributes of A are also copied into the complementary attributes of B when the code of the attribute is the same. +ThereIsMoreThanXAnswers=There is more than %s answers with your filter. Please add more filters... diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 527e967a9ff..1dd88cc04d6 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -290,7 +290,7 @@ showAll=Show all showing= Showing nbrOfProducts= There are %s products. noResultsHaveBeenFound=0 results have been found. -noResultsWereFound= No results were found. +noResultsWereFound=No results were found. addToCart=Add to cart backHome=Return to Home priceDrop=Price drop