forked from Wavyzz/dolibarr
NEW Can replace a string into all pages in website module
This commit is contained in:
@@ -722,6 +722,7 @@ class Form
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
jQuery(".massaction").hide();
|
jQuery(".massaction").hide();
|
||||||
|
jQuery(".massactionother").hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,10 +744,12 @@ class Form
|
|||||||
if ($(this).val() != \'0\')
|
if ($(this).val() != \'0\')
|
||||||
{
|
{
|
||||||
jQuery(".massactionconfirmed").prop(\'disabled\', false);
|
jQuery(".massactionconfirmed").prop(\'disabled\', false);
|
||||||
|
jQuery(".massactionother").show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jQuery(".massactionconfirmed").prop(\'disabled\', true);
|
jQuery(".massactionconfirmed").prop(\'disabled\', true);
|
||||||
|
jQuery(".massactionother").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
|
|||||||
{
|
{
|
||||||
$tmpwebsitepage = new WebsitePage($db);
|
$tmpwebsitepage = new WebsitePage($db);
|
||||||
$tmpwebsitepage->fetch($obj->rowid);
|
$tmpwebsitepage->fetch($obj->rowid);
|
||||||
if ($tmpwebsitepage->id > 0) $arrayresult['list'][] = $tmpwebsitepage;
|
if ($tmpwebsitepage->id > 0) $arrayresult['list'][$obj->rowid] = $tmpwebsitepage;
|
||||||
$found++;
|
$found++;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@@ -126,4 +126,5 @@ MainLanguage=Main language
|
|||||||
OtherLanguages=Other languages
|
OtherLanguages=Other languages
|
||||||
UseManifest=Provide a manifest.json file
|
UseManifest=Provide a manifest.json file
|
||||||
PublicAuthorAlias=Public author alias
|
PublicAuthorAlias=Public author alias
|
||||||
AvailableLanguagesAreDefinedIntoWebsiteProperties=Available languages are defined into website properties
|
AvailableLanguagesAreDefinedIntoWebsiteProperties=Available languages are defined into website properties
|
||||||
|
ReplacementDoneInXPages=Replacement done in %s pages or containers
|
||||||
@@ -52,9 +52,12 @@ $websitekey = GETPOST('website', 'alpha');
|
|||||||
$page = GETPOST('page', 'alpha');
|
$page = GETPOST('page', 'alpha');
|
||||||
$pageid = GETPOST('pageid', 'int');
|
$pageid = GETPOST('pageid', 'int');
|
||||||
$pageref = GETPOST('pageref', 'alphanohtml');
|
$pageref = GETPOST('pageref', 'alphanohtml');
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||||
$confirm = GETPOST('confirm', 'alpha');
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
$cancel = GETPOST('cancel', 'alpha');
|
$cancel = GETPOST('cancel', 'alpha');
|
||||||
|
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
|
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
|
||||||
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||||
@@ -260,6 +263,23 @@ $manifestjsoncontentdefault .= '{
|
|||||||
}]
|
}]
|
||||||
}';
|
}';
|
||||||
|
|
||||||
|
$listofpages = array();
|
||||||
|
|
||||||
|
$algo = '';
|
||||||
|
if (GETPOST('optionmeta')) $algo .= 'meta';
|
||||||
|
if (GETPOST('optioncontent')) $algo .= 'content';
|
||||||
|
if (GETPOST('optionsitefiles')) $algo .= 'sitefiles';
|
||||||
|
|
||||||
|
if (empty($sortfield)) {
|
||||||
|
$sortfield = 'pageurl'; $sortorder = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
$searchkey = GETPOST('searchstring', 'none');
|
||||||
|
|
||||||
|
if ($action == 'replacesiteconfirm') {
|
||||||
|
$listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -340,11 +360,67 @@ if ($action == 'unsetshowsubcontainers')
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($action == 'replacesite' || $action == 'replacesiteconfirm') && empty(GETPOST('searchstring')))
|
if (($action == 'replacesite' || $action == 'replacesiteconfirm') && ! $searchkey)
|
||||||
{
|
{
|
||||||
$action = 'replacesite';
|
$action = 'replacesite';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replacement of string into pages
|
||||||
|
if ($massaction == 'replace')
|
||||||
|
{
|
||||||
|
$replacestring = GETPOST('replacestring', 'alphanohtml');
|
||||||
|
if (! $replacestring) {
|
||||||
|
setEventMessages("ErrorReplaceStringEmpty", null, 'errors');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nbreplacement = 0;
|
||||||
|
|
||||||
|
foreach($toselect as $keyselected) {
|
||||||
|
$objectpage = $listofpages['list'][$keyselected];
|
||||||
|
if ($objectpage->pageurl) {
|
||||||
|
dol_syslog("Replace string into page ".$objectpage->pageurl);
|
||||||
|
|
||||||
|
if (GETPOST('optioncontent', 'aZ09')) {
|
||||||
|
$objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
|
||||||
|
}
|
||||||
|
if (GETPOST('optionmeta', 'aZ09')) {
|
||||||
|
$objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
|
||||||
|
$objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
|
||||||
|
$objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($objectpage->content))
|
||||||
|
{
|
||||||
|
$filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php';
|
||||||
|
$filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php';
|
||||||
|
|
||||||
|
// Save page alias
|
||||||
|
$result = dolSavePageAlias($filealias, $object, $objectpage);
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
setEventMessages('Failed to write file '.basename($filealias), null, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save page of content
|
||||||
|
$result = dolSavePageContent($filetpl, $object, $objectpage);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$nbreplacement++;
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
||||||
|
$action = 'createcontainer';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $error) {
|
||||||
|
setEventMessages($langs->trans("ReplacementDoneInXPages", $nbreplacement), null, 'mesgs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add directory
|
// Add directory
|
||||||
/*
|
/*
|
||||||
@@ -3397,10 +3473,8 @@ print "</div>\n";
|
|||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction == 'replace')
|
||||||
{
|
{
|
||||||
$searchkey = GETPOST('searchstring', 'none');
|
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||||
@@ -3431,37 +3505,53 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="tagtd">';
|
print '<div class="tagtd">';
|
||||||
print '<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey).'" autofocus>';
|
print '<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey).'" autofocus>';
|
||||||
print '</div>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="'.$langs->trans("Search").'">';
|
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="'.$langs->trans("Search").'">';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'replacesiteconfirm')
|
if ($action == 'replacesiteconfirm')
|
||||||
{
|
{
|
||||||
$algo = '';
|
|
||||||
if (GETPOST('optionmeta')) $algo .= 'meta';
|
|
||||||
if (GETPOST('optioncontent')) $algo .= 'content';
|
|
||||||
if (GETPOST('optionsitefiles')) $algo .= 'sitefiles';
|
|
||||||
|
|
||||||
if (empty($sortfield)) {
|
|
||||||
$sortfield = 'pageurl'; $sortorder = 'ASC';
|
|
||||||
}
|
|
||||||
|
|
||||||
$listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000, $sortfield, $sortorder);
|
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
if ($listofpages['code'] == 'OK')
|
if ($listofpages['code'] == 'OK')
|
||||||
{
|
{
|
||||||
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
$param = '';
|
||||||
|
$nbtotalofrecords = count($listofpages['list']);
|
||||||
|
$num = $nbtotalofrecords = $limit;
|
||||||
|
$permissiontodelete = 0;
|
||||||
|
|
||||||
|
// List of mass actions available
|
||||||
|
$arrayofmassactions = array(
|
||||||
|
//'validate'=>$langs->trans("Validate"),
|
||||||
|
//'generate_doc'=>$langs->trans("ReGeneratePDF"),
|
||||||
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
|
'replace'=>$langs->trans("Replace"),
|
||||||
|
);
|
||||||
|
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||||
|
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
||||||
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
$massactionbutton .= '<div class="massactionother hidden">';
|
||||||
|
$massactionbutton .= $langs->trans("ReplaceString");
|
||||||
|
$massactionbutton .= '<input type="text" name="replacestring" value="'.dol_escape_htmltag(GETPOST('replacestring', 'none')).'">';
|
||||||
|
$massactionbutton .='</div>';
|
||||||
|
|
||||||
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
|
//$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||||
|
|
||||||
|
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 '<!-- List of search result -->'."\n";
|
||||||
print '<div class="rowsearchresult">';
|
print '<div class="rowsearchresult">';
|
||||||
|
|
||||||
if ($action == 'replacesiteconfirm' && $conf->global->MAIN_FEATURES_LEVEL >= 2)
|
/*if ($action == 'replacesiteconfirm')
|
||||||
{
|
{
|
||||||
print '<div class="tagtr">';
|
print '<div class="tagtr">';
|
||||||
print '<div class="tagtd paddingrightonly">';
|
print '<div class="tagtd paddingrightonly">';
|
||||||
@@ -3469,11 +3559,11 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="tagtd">';
|
print '<div class="tagtd">';
|
||||||
print '<input type="text" name="replacestring" value="'.dol_escape_htmltag(GETPOST('replacestring', 'none')).'">';
|
print '<input type="text" name="replacestring" value="'.dol_escape_htmltag(GETPOST('replacestring', 'none')).'">';
|
||||||
print '<input type="submit" disabled class="button" name="buttonreplacesitesearch" value="'.$langs->trans("Replace").'">';
|
print '<input type="submit" class="button" name="buttonreplacesitereplace" value="'.$langs->trans("Replace").'">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$param = 'action=replacesiteconfirm&website='.urlencode($website->ref);
|
$param = 'action=replacesiteconfirm&website='.urlencode($website->ref);
|
||||||
$param .= '&searchstring='.urlencode($searchkey);
|
$param .= '&searchstring='.urlencode($searchkey);
|
||||||
@@ -3488,6 +3578,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
|||||||
print getTitleFieldOfList("Page", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n";
|
print getTitleFieldOfList("Page", 0, $_SERVER['PHP_SELF'], 'pageurl', '', $param, '', $sortfield, $sortorder, '')."\n";
|
||||||
//print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n";
|
//print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n";
|
||||||
print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']);
|
print getTitleFieldOfList("", 0 , $_SERVER['PHP_SELF']);
|
||||||
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
foreach ($listofpages['list'] as $answerrecord)
|
foreach ($listofpages['list'] as $answerrecord)
|
||||||
@@ -3521,6 +3612,17 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
|||||||
}
|
}
|
||||||
print '<a class="editfielda '.$disabled.'" href="'.$urltoedithtmlsource.'" title="'.$langs->trans("EditHTMLSource").'">'.img_picto($langs->trans("EditHTMLSource"), 'edit').'</a>';
|
print '<a class="editfielda '.$disabled.'" href="'.$urltoedithtmlsource.'" title="'.$langs->trans("EditHTMLSource").'">'.img_picto($langs->trans("EditHTMLSource"), 'edit').'</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
// Action column
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
if ($massactionbutton || $massaction)
|
||||||
|
{
|
||||||
|
$selected = 0;
|
||||||
|
if (in_array($answerrecord->id, $arrayofselected)) $selected = 1;
|
||||||
|
print '<input id="'.$answerrecord->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3550,11 +3652,17 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
|||||||
print '<td class="tdoverflow100">';
|
print '<td class="tdoverflow100">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
|
|
||||||
|
// Action column
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
|
print '<br>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user