NEW Can filter on container type, language and tags in the list of pages
of website module.
This commit is contained in:
parent
b6308f6dfa
commit
2d30d33303
@ -248,7 +248,7 @@ print '</tr>';
|
||||
|
||||
// Default language
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
|
||||
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 '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
|
||||
print '</td>';
|
||||
print '<td width="20"> </td>';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
|
||||
print '<div class="tagtable">';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly">';
|
||||
print '<div class="tagtd paddingrightonly opacitymedium">';
|
||||
print $langs->trans("SearchReplaceInto");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
@ -3561,23 +3577,64 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction =
|
||||
print '</div>';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly">';
|
||||
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
|
||||
print $langs->trans("SearchString");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
|
||||
print '<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0, '', 1).'" autofocus>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '</div><div class="fichehalfleft">';
|
||||
|
||||
print '<div class="tagtable">';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
|
||||
print $langs->trans("WEBSITE_TYPE_CONTAINER");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
print $formwebsite->selectTypeOfContainer('optioncontainertype', (GETPOST('optioncontainertype', 'alpha') ? GETPOST('optioncontainertype', 'alpha') : ''), 1);
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
|
||||
print $langs->trans("Language");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
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 '</div>';
|
||||
print '</div>';
|
||||
|
||||
// Categories
|
||||
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
|
||||
{
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly marginrightonly opacitymedium" style="padding-right: 10px !important">';
|
||||
print $langs->trans("Category");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
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 '</div>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '</div></div>';
|
||||
|
||||
if ($action == 'replacesiteconfirm')
|
||||
{
|
||||
print '<!-- List of search result -->'."\n";
|
||||
print '<div class="rowsearchresult clearboth">';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
@ -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 '<!-- List of search result -->'."\n";
|
||||
print '<div class="rowsearchresult">';
|
||||
|
||||
$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 '</table>';
|
||||
print '</div></div>';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
}
|
||||
else {
|
||||
print $listofpages['message'];
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user