Debug v21

This commit is contained in:
Laurent Destailleur 2024-11-08 14:21:52 +01:00
parent 13e7cefe39
commit b232bb8d45
15 changed files with 91 additions and 40 deletions

View file

@ -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 '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
$previouslink = $dolistore->get_previous_link();
$nextlink = $dolistore->get_next_link();
$previouslink = $remotestore->get_previous_link();
$nextlink = $remotestore->get_next_link();
print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
print '<form method="POST" class="centpercent" id="searchFormList" action="'.$dolistore->url.'">'; ?>
print '<form method="POST" class="centpercent" id="searchFormList" action="'.$remotestore->url.'">'; ?>
<input type="hidden" name="token" value="<?php echo newToken(); ?>">
<input type="hidden" name="mode" value="marketplace">
<div class="divsearchfield">
@ -1289,7 +1293,7 @@ if ($mode == 'marketplace') {
</div>
<div class="divsearchfield">
<input class="button buttongen" value="<?php echo $langs->trans('Rechercher') ?>" type="submit">
<a class="buttonreset" href="<?php echo urlencode($dolistore->url) ?>"><?php echo $langs->trans('Reset') ?></a>
<a class="buttonreset" href="<?php echo $_SERVER["PHP_SELF"].'?mode=marketplace'; ?>"><?php echo $langs->trans('Reset') ?></a>
&nbsp;
</div>
@ -1305,13 +1309,14 @@ if ($mode == 'marketplace') {
<div id="category-tree-left">
<ul class="tree">
<?php
echo $dolistore->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?>
</ul>
</div>
<div id="listing-content">
<table summary="list_of_modules" id="list_of_modules" class="productlist centpercent">
<tbody id="listOfModules">
<?php echo $dolistore->get_products(); ?>
<?php echo $remotestore->get_products($nbmaxtoshow); ?>
</tbody>
</table>
</div>

View file

@ -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';
/*

View file

@ -50,4 +50,3 @@ e) to display the Original Work publicly.
[0]: http://rosenlaw.com/OSL3.0-explained.htm

View file

@ -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.

View file

@ -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 .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.((int) $cat->id).'" ';
$html .= 'title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang - 1])).'">'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' <sup>'.dol_escape_htmltag($cat->nb_products_recursive).'</sup></a></h3>';
$html .= '<li class="root"><h3 class="nomargesupinf marginleftonly"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.((int) $cat->id).'" ';
$html .= 'title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang - 1])).'">';
//$html .= dol_escape_htmltag($cat->name->language[$this->lang - 1]);
$html .= 'DoliStore';
$html .= ' &nbsp;<span class="opacitymedium small valignmiddle">('.dol_escape_htmltag($cat->nb_products_recursive).')</span></a></h3>';
$html .= self::get_categories((int) $cat->id);
$html .= "</li>\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 .= '<li><a class="link2cat'.$select.'" href="?mode=marketplace&categorie='.((int) $cat->id).'"';
$html .= ' title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang - 1])).'" ';
$html .= '>'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' <sup>'.dol_escape_htmltag($cat->nb_products_recursive).'</sup></a>';
$html .= '>'.dol_escape_htmltag($cat->name->language[$this->lang - 1]);
$html .= ' &nbsp;<span class="opacitymedium small valignmiddle">('.dol_escape_htmltag($cat->nb_products_recursive).')</span></a>';
$html .= self::get_categories((int) $cat->id);
$html .= "</li>\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 = '<a href="'.$image_url.'" class="documentpreview" target="_blank" rel="noopener noreferrer" mime="image/png" title="'.dol_escape_htmltag($product->name->language[$this->lang - 1].', '.$langs->trans('Version').' '.$product->module_version).'">';
$images .= '<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>';
$images .= '<img class="imgstore" src="'.$image_url.'&quality=home_default" alt="" /></a>';
} else {
$images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
$images = '<img class="imgstore" src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
}
// free or pay ?
@ -318,8 +336,8 @@ class Dolistore
$download_link = '<a target="_blank" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} else {
$price = '<h3>'.$langs->trans('Free').'</h3>';
$download_link = '<a target="_blank" rel="noopener noreferrer" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>';
$download_link .= '<br><br><a target="_blank" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
$download_link = '<a class="paddingleft paddingright" target="_blank" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
$download_link .= '<a class="paddingleft paddingright" target="_blank" rel="noopener noreferrer" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>';
}
// Set and check version
@ -357,22 +375,42 @@ class Dolistore
//output template
$html .= '<tr class="app oddeven '.dol_escape_htmltag($compatible).'">';
$html .= '<td class="center" width="210"><div class="newAppParent">';
$html .= '<td class="center" width="160"><div class="newAppParent">';
$html .= $newapp.$images; // No dol_escape_htmltag, it is already escape html
$html .= '</div></td>';
$html .= '<td class="margeCote"><h2 class="appTitle">';
$html .= dol_escape_htmltag($product->name->language[$this->lang - 1]);
$html .= dol_escape_htmltag(dol_string_nohtmltag($product->name->language[$this->lang - 1]));
$html .= '<br><small>';
$html .= $version; // No dol_escape_htmltag, it is already escape html
$html .= '</small></h2>';
$html .= '<small> '.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).'</small><br><br>'.dol_escape_htmltag($product->description_short->language[$this->lang - 1]).'</td>';
$html .= '<small> '.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).'</small><br>';
$html .= '<br>'.dol_escape_htmltag(dol_string_nohtmltag($product->description_short->language[$this->lang - 1]));
$html.= '</td>';
// do not load if display none
$html .= '<td class="margeCote center">';
$html .= '<td class="margeCote center amount">';
$html .= $price;
$html .= '</td>';
$html .= '<td class="margeCote">'.$download_link.'</td>';
$html .= '<td class="margeCote nowraponall">'.$download_link.'</td>';
$html .= '</tr>';
}
if (empty($this->products)) {
$html .= '<tr class=""><td colspan="3" class="center">';
$html .= '<br><br>';
$langs->load("website");
$html .= $langs->trans("noResultsWereFound").'...';
$html .= '<br><br>';
$html .= '</td></tr>';
}
if (count($this->products) > $nbmaxtoshow) {
$html .= '<tr class=""><td colspan="3" class="center">';
$html .= '<br><br>';
$html .= $langs->trans("ThereIsMoreThanXAnswers", $nbmaxtoshow).'...';
$html .= '<br><br>';
$html .= '</td></tr>';
}
return $html;
}

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 364 B

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 9 KiB

After

Width:  |  Height:  |  Size: 9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 943 B

After

Width:  |  Height:  |  Size: 943 B

View file

@ -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 <a href="%s">this tool</a>.
AttributeCodeHelp=A code of your choice (without special char and space) to identify the property.<br>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...

View file

@ -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