NEW Add feature to search a string into containers
This commit is contained in:
parent
8ad2081555
commit
7824731f17
@ -17,8 +17,7 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/pingresult.php
|
||||
* \brief File to save result of anonymous ping
|
||||
* Example: captureserver/public/index.php?action=dolibarrping
|
||||
* \brief File to save result of an anonymous ping into database (1 ping is done per installation)
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
|
||||
@ -575,6 +575,8 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25)
|
||||
$error = 0;
|
||||
$arrayresult = array('code'=>'', 'list'=>array());
|
||||
|
||||
if (! is_object($weblangs)) $weblangs = $langs;
|
||||
|
||||
if (empty($searchstring))
|
||||
{
|
||||
$error++;
|
||||
@ -583,24 +585,38 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25)
|
||||
}
|
||||
elseif (dol_strlen($searchstring) < 2)
|
||||
{
|
||||
$weblangs->load("errors");
|
||||
$error++;
|
||||
$arrayresult['code']='KO';
|
||||
$arrayresult['message']=$weblangs->trans("SearchCriteriaTooSmall");
|
||||
$arrayresult['message']=$weblangs->trans("ErrorSearchCriteriaTooSmall");
|
||||
}
|
||||
elseif (! in_array($type, array('page')))
|
||||
elseif (! in_array($type, array('', 'page')))
|
||||
{
|
||||
$error++;
|
||||
$arrayresult['code']='KO';
|
||||
$arrayresult['message']='Bad value for parameter $type';
|
||||
}
|
||||
|
||||
if (! $error && in_array($algo, array('meta', 'metacontent')))
|
||||
$searchdone = 0;
|
||||
|
||||
if (! $error && in_array($algo, array('meta', 'metacontent', 'content')))
|
||||
{
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page';
|
||||
$sql.= " WHERE fk_website = ".$website->id." AND type_container = '".$db->escape($type)."'";
|
||||
$sql.= " AND (title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'";
|
||||
if ($algo == 'metacontent') $sql.= " OR content LIKE '%".$db->escape($searchstring)."%'";
|
||||
$sql.= " OR keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%')"; // TODO Use a better way to scan keywords
|
||||
$sql.= " WHERE fk_website = ".$website->id;
|
||||
if ($type) $sql.= " AND type_container = '".$db->escape($type)."'";
|
||||
$sql.= " AND (";
|
||||
$searchalgo = '';
|
||||
if ($algo == 'meta' || $algo == 'metacontent')
|
||||
{
|
||||
$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
|
||||
}
|
||||
if ($algo == 'metacontent' || $algo == 'content')
|
||||
{
|
||||
$searchalgo.= ($searchalgo?' OR ':'')."content LIKE '%".$db->escape($searchstring)."%'";
|
||||
}
|
||||
$sql.=$searchalgo;
|
||||
$sql.= ")";
|
||||
$sql.= $db->plimit($max);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -631,6 +647,15 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25)
|
||||
$arrayresult['code']=$db->lasterrno();
|
||||
$arrayresult['message']=$db->lasterror();
|
||||
}
|
||||
|
||||
$searchdone = 1;
|
||||
}
|
||||
|
||||
if (! $searchdone)
|
||||
{
|
||||
$error++;
|
||||
$arrayresult['code']='KO';
|
||||
$arrayresult['message']='No supported algorithm found';
|
||||
}
|
||||
|
||||
return $arrayresult;
|
||||
|
||||
@ -218,6 +218,7 @@ ErrorVariableKeyForContentMustBeSet=Error, the constant with name %s (with text
|
||||
ErrorURLMustStartWithHttp=URL %s must start with http:// or https://
|
||||
ErrorNewRefIsAlreadyUsed=Error, the new reference is already used
|
||||
ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible=Error, delete payment linked to a closed invoice is not possible.
|
||||
ErrorSearchCriteriaTooSmall=Search criteria too small.
|
||||
# Warnings
|
||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.
|
||||
|
||||
@ -103,4 +103,6 @@ NotAllowedToAddDynamicContent=You don't have permission to add or edit PHP dynam
|
||||
ReplaceWebsiteContent=Search or Replace website content
|
||||
DeleteAlsoJs=Delete also all javascript files specific to this website?
|
||||
DeleteAlsoMedias=Delete also all medias files specific to this website?
|
||||
MyWebsitePages=My website pages
|
||||
MyWebsitePages=My website pages
|
||||
SearchReplaceInto=Search | Replace into
|
||||
ReplaceString=New string
|
||||
@ -2344,7 +2344,7 @@ if (! function_exists("llxFooter"))
|
||||
url: "https://ping.dolibarr.org/",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo md5($conf->file->instance_unique_id); ?>", action: "dolibarrping", version: "<?php echo (float) DOL_VERSION; ?>", entity: <?php echo (int) $conf->entity; ?> },
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo md5('dolibarr'.$conf->file->instance_unique_id); ?>", action: "dolibarrping", version: "<?php echo (float) DOL_VERSION; ?>", entity: <?php echo (int) $conf->entity; ?> },
|
||||
success: function (data, status, xhr) { // success callback function (data contains body of response)
|
||||
console.log("Ping ok");
|
||||
$.ajax({
|
||||
|
||||
@ -302,6 +302,12 @@ if ($action == 'unsetshowsubcontainers')
|
||||
exit;
|
||||
}
|
||||
|
||||
if (($action == 'replacesite' || $action == 'replacesiteconfirm') && empty(GETPOST('searchstring')))
|
||||
{
|
||||
$action = 'replacesite';
|
||||
}
|
||||
|
||||
|
||||
// Add directory
|
||||
/*
|
||||
if ($action == 'adddir' && $permtouploadfile)
|
||||
@ -1793,9 +1799,10 @@ $moreheadjs.='</script>'."\n";
|
||||
|
||||
llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">');
|
||||
|
||||
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
|
||||
|
||||
print "\n";
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
if ($action == 'createsite')
|
||||
{
|
||||
print '<input type="hidden" name="action" value="addsite">';
|
||||
@ -1842,7 +1849,11 @@ if ($action == 'file_manager')
|
||||
}
|
||||
if ($action == 'replacesite')
|
||||
{
|
||||
print '<input type="hidden" name="action" value="replacesite">';
|
||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||
}
|
||||
if ($action == 'replacesiteconfirm')
|
||||
{
|
||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||
}
|
||||
|
||||
print '<div>';
|
||||
@ -1954,7 +1965,6 @@ if (! GETPOST('hide_websitemenu'))
|
||||
</script>';
|
||||
*/
|
||||
|
||||
//print '<input type="submit" class="button nobordertransp"'.$disabled.' value="<span class="fa fa-globe"><span>'.dol_escape_htmltag($langs->trans("Replace")).'" name="replacesite">';
|
||||
print '<a href="'.$_SERVER["PHP_SEFL"].'?action=replacesite&website='.$website->ref.'" class="button nobordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'"><span class="fa fa-file-code"><span></a>';
|
||||
}
|
||||
|
||||
@ -2005,10 +2015,10 @@ if (! GETPOST('hide_websitemenu'))
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if (in_array($action, array('editcss','editmenu','file_manager','replacesite')))
|
||||
if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm')))
|
||||
{
|
||||
if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
|
||||
}
|
||||
|
||||
@ -2286,7 +2296,7 @@ if (! GETPOST('hide_websitemenu'))
|
||||
|
||||
// TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext
|
||||
}
|
||||
if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','createsite','createcontainer','createfromclone','createpagefromclone','deletesite')))
|
||||
if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm','createsite','createcontainer','createfromclone','createpagefromclone','deletesite')))
|
||||
{
|
||||
if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
@ -2992,18 +3002,6 @@ if ($action == 'editfile' || $action == 'file_manager')
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($action == 'replacesite')
|
||||
{
|
||||
print '<!-- Edit Media -->'."\n";
|
||||
print '<div class="fiche"><br>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ReplaceWebsiteContent"));
|
||||
|
||||
print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($action == 'editmenu')
|
||||
{
|
||||
print '<!-- Edit Menu -->'."\n";
|
||||
@ -3053,6 +3051,85 @@ print "</div>\n";
|
||||
print "</form>\n";
|
||||
|
||||
|
||||
if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
||||
{
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||
|
||||
|
||||
print '<!-- Edit Media -->'."\n";
|
||||
print '<div class="fiche"><br>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ReplaceWebsiteContent"));
|
||||
|
||||
print '<div class="tagtable">';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly">';
|
||||
print $langs->trans("SearchReplaceInto");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
print '<input type="checkbox" name="optioncontent" value="content"'.((! GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09'))?' checked':'').'> '.$langs->trans("Content");
|
||||
print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09')?' checked':'').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords");
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly">';
|
||||
print $langs->trans("SearchString");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
print '<input type="text" name="searchstring" value="'.dol_escape_htmltag(GETPOST('searchstring', 'none')).'">';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="'.$langs->trans("Search").'">';
|
||||
|
||||
if ($action == 'replacesiteconfirm')
|
||||
{
|
||||
$algo = '';
|
||||
if (GETPOST('optionmeta')) $algo.='meta';
|
||||
if (GETPOST('optioncontent')) $algo.='content';
|
||||
|
||||
$listofpages = getPagesFromSearchCriterias('', $algo, GETPOST('searchstring', 'none'), 1000);
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
if ($listofpages['code'] == 'OK')
|
||||
{
|
||||
foreach($listofpages['list'] as $websitepagefound)
|
||||
{
|
||||
print '<div class="rowsearchresult"><a href="'.$_SERVER["PHP_SELF"].'?website='.$website->ref.'&pageid='.$websitepagefound->id.'">'.$websitepagefound->title.'</a> - '.$websitepagefound->description.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $listofpages['message'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'replacesiteconfirm')
|
||||
{
|
||||
print '<div class="tagtr">';
|
||||
print '<div class="tagtd paddingrightonly">';
|
||||
print $langs->trans("ReplaceString");
|
||||
print '</div>';
|
||||
print '<div class="tagtd">';
|
||||
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 '</div>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')
|
||||
{
|
||||
if ($pageid > 0 && $atleastonepage)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user