diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index b6233f13146..e1be556d906 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -248,7 +248,7 @@ print '';
// Default language
print '
| '.$langs->trans("DefaultLanguage").' | ';
-print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 2);
+print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, null, '', 0, 0, 'minwidth300', 2);
print '';
print ' | ';
print ' | ';
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 4bebc0c0081..ebbaf4ec775 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -768,9 +768,10 @@ function getSocialNetworkSharingLinks()
* @param string $sortfield Sort Fields
* @param string $sortorder Sort order ('DESC' or 'ASC')
* @param string $langcode Language code ('' or 'en', 'fr', 'es', ...)
+ * @param array $otherfilters Other filters
* @return string HTML content
*/
-function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield = 'date_creation', $sortorder = 'DESC', $langcode = '')
+function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield = 'date_creation', $sortorder = 'DESC', $langcode = '', $otherfilters = 'null')
{
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
@@ -784,8 +785,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$error++;
$arrayresult['code'] = 'KO';
$arrayresult['message'] = $weblangs->trans("EmptySearchString");
- } elseif (dol_strlen($searchstring) < 2)
- {
+ } elseif (dol_strlen($searchstring) < 2) {
$weblangs->load("errors");
$error++;
$arrayresult['code'] = 'KO';
@@ -807,10 +807,13 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
if (!$error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo)))
{
- $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page';
- $sql .= " WHERE fk_website = ".$website->id;
+ $sql = 'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.'website_page as wp';
+ if (is_array($otherfilters) && ! empty($otherfilters['category'])) {
+ $sql .= ', '.MAIN_DB_PREFIX.'categorie_website_page as cwp';
+ }
+ $sql .= " WHERE wp.fk_website = ".$website->id;
if ($langcode) {
- $sql .= " AND lang ='".$db->escape($langcode)."'";
+ $sql .= " AND wp.lang ='".$db->escape($langcode)."'";
}
if ($type) {
$tmparrayoftype = explode(',', $type);
@@ -818,20 +821,23 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
foreach ($tmparrayoftype as $tmptype) {
$typestring .= ($typestring ? ", " : "")."'".trim($tmptype)."'";
}
- $sql .= " AND type_container IN (".$typestring.")";
+ $sql .= " AND wp.type_container IN (".$typestring.")";
}
$sql .= " AND (";
$searchalgo = '';
if (preg_match('/meta/', $algo))
{
- $searchalgo .= ($searchalgo ? ' OR ' : '')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'";
- $searchalgo .= ($searchalgo ? ' OR ' : '')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escape($searchstring)."%' OR wp.description LIKE '%".$db->escape($searchstring)."%'";
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escape($searchstring).",%' OR wp.keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords
}
if (preg_match('/content/', $algo))
{
- $searchalgo .= ($searchalgo ? ' OR ' : '')."content LIKE '%".$db->escape($searchstring)."%'";
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escape($searchstring)."%'";
}
$sql .= $searchalgo;
+ if (is_array($otherfilters) && ! empty($otherfilters['category'])) {
+ $sql .= ' AND cwp.fk_website_page = wp.rowid AND cwp.fk_categorie = '.((int) $otherfilters['category']);
+ }
$sql .= ")";
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($max);
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 9babe86d341..9b704405559 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -282,7 +282,14 @@ if (empty($sortfield)) {
$searchkey = GETPOST('searchstring', 'none');
if ($action == 'replacesiteconfirm') {
- $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder);
+ $containertype = GETPOST('optioncontainertype', 'aZ09') != '-1' ? GETPOST('optioncontainertype', 'aZ09') : '';
+ $langcode = GETPOST('optionlanguage', 'aZ09');
+ $otherfilters = array();
+ if (GETPOST('optioncategory', 'int') > 0) {
+ $otherfilters['category'] = GETPOST('optioncategory', 'int');
+ }
+
+ $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
}
@@ -430,8 +437,15 @@ if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha'))
setEventMessages($langs->trans("ReplacementDoneInXPages", $nbreplacement), null, 'mesgs');
}
+ $containertype = GETPOST('optioncontainertype', 'aZ09') != '-1' ? GETPOST('optioncontainertype', 'aZ09') : '';
+ $langcode = GETPOST('optionlanguage', 'aZ09');
+ $otherfilters = array();
+ if (GETPOST('optioncategory', 'int') > 0) {
+ $otherfilters['category'] = GETPOST('optioncategory', 'int');
+ }
+
// Now we reload list
- $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder);
+ $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
}
}
@@ -3547,10 +3561,12 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
print load_fiche_titre($langs->trans("ReplaceWebsiteContent"), '', 'search');
+ print '';
+
print '
';
print '
';
- print '
';
+ print '
';
print $langs->trans("SearchReplaceInto");
print '
';
print '
';
@@ -3561,23 +3577,64 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
print '
';
print '
';
- print '
';
+ print '
';
print $langs->trans("SearchString");
print '
';
print '
';
-
print '';
+ print '
';
+ print '
';
+
+ print '
';
+
+ print '
';
+
+ print '
';
+
+ print '
';
+ print '
';
+ print $langs->trans("WEBSITE_TYPE_CONTAINER");
+ print '
';
+ print '
';
+ print $formwebsite->selectTypeOfContainer('optioncontainertype', (GETPOST('optioncontainertype', 'alpha') ? GETPOST('optioncontainertype', 'alpha') : ''), 1);
+ print '
';
+ print '
';
+
+ print '
';
+ print '
';
+ print $langs->trans("Language");
+ print '
';
+ print '
';
+ print img_picto('', 'language', 'class="paddingrightonly"').' '.$formadmin->select_language(GETPOSTISSET('optionlanguage') ? GETPOST('optionlanguage') : '', 'optionlanguage', 0, null, '1', 0, 0, 'minwidth300', 2, 0, 0, null, 1);
+ print '
';
+ print '
';
+
+ // Categories
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
+ {
+ print '
';
+ print '
';
+ print $langs->trans("Category");
+ print '
';
+ print '
';
+ print img_picto('', 'category', 'class="paddingrightonly"').' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET('optioncategory') ? GETPOST('optioncategory') : '', 'optioncategory', null, null);
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+ print ajax_combobox('optioncategory');
+ print '
';
+ print '
';
+ }
+
+ print '
';
print '
';
- print '
';
- print '
';
-
- print '
';
-
+ print '
';
if ($action == 'replacesiteconfirm')
{
+ print ''."\n";
+ print '';
+
print '
';
print '
';
@@ -3606,9 +3663,6 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit, 1, 1, 1);
- print ''."\n";
- print '
';
-
$param = 'action=replacesiteconfirm&website='.urlencode($website->ref);
$param .= '&searchstring='.urlencode($searchkey);
if (GETPOST('optioncontent')) $param .= '&optioncontent=content';
@@ -3727,12 +3781,14 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
}
}
print '';
- print '
';
+ print '';
print '
';
}
else {
print $listofpages['message'];
}
+
+ print '';
}
print '';