diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index af0114c9c97..60016b2f2e9 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -725,37 +725,39 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) if (! $error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website'; - $sql.= " WHERE rowid = ".$website->id; - $sql.= " AND ("; - $searchalgo = ''; - // TODO - $searchalgo.= '...'; + global $dolibarr_main_data_root; - $sql.=$searchalgo; - $sql.= ")"; - $sql.= $db->plimit($max); + $pathofwebsite=$dolibarr_main_data_root.'/website/'.$website->ref; + $filehtmlheader=$pathofwebsite.'/htmlheader.html'; + $filecss=$pathofwebsite.'/styles.css.php'; + $filejs=$pathofwebsite.'/javascript.js.php'; + $filerobot=$pathofwebsite.'/robots.txt'; + $filehtaccess=$pathofwebsite.'/.htaccess'; + $filemanifestjson=$pathofwebsite.'/manifest.json.php'; + $filereadme=$pathofwebsite.'/README.md'; - $resql = $db->query($sql); - if ($resql) + $filecontent = file_get_contents($filehtmlheader); + if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $i = 0; - while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0)) - { - if ($obj->rowid > 0) - { - $tmpwebsitepage = new WebsitePage($db); - $tmpwebsitepage->fetch($obj->rowid); - if ($tmpwebsitepage->id > 0) $arrayresult['list'][]=$tmpwebsitepage; - } - $i++; - } + $arrayresult['list'][]=array('type'=>'website_htmlheadercontent'); } - else + + $filecontent = file_get_contents($filecss); + if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) { - $error++; - $arrayresult['code']=$db->lasterrno(); - $arrayresult['message']=$db->lasterror(); + $arrayresult['list'][]=array('type'=>'website_csscontent'); + } + + $filecontent = file_get_contents($filejs); + if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) + { + $arrayresult['list'][]=array('type'=>'website_jscontent'); + } + + $filerobot = file_get_contents($filerobot); + if ((empty($max) || ($found < $max)) && preg_match('/'.preg_quote($searchstring, '/').'/', $filecontent)) + { + $arrayresult['list'][]=array('type'=>'website_robotcontent'); } $searchdone = 1; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f98024a726d..1a2dc531dd1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -53,6 +53,9 @@ $pageref=GETPOST('pageref', 'aZ09'); $action=GETPOST('action', 'aZ09'); $confirm=GETPOST('confirm', 'alpha'); $cancel=GETPOST('cancel', 'alpha'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $type_container=GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); @@ -270,9 +273,21 @@ if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETP } if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) $action='preview'; +// Cancel +if ($cancel) +{ + $action = 'preview'; + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } +} -$backtopage=$_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php +$savbacktopage = $backtopage; +$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +$backtopage = $savbacktopage; if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' @@ -984,7 +999,8 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshpage', 'alpha')) // If we tried to reload another site/page, we stay on editcss mode. + // If we tried to reload another site/page, we stay on editcss mode. + if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) { $action='editcss'; } @@ -1221,6 +1237,12 @@ if ($action == 'updatecss') } $action='preview'; + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } } } } @@ -1861,6 +1883,7 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $help_url, '' print "\n"; print '
'; }