mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-30 13:21:30 +01:00
Work on website
This commit is contained in:
@@ -2775,7 +2775,7 @@ function dol_print_error($db='',$error='',$errors=null)
|
||||
|
||||
foreach($errors as $msg)
|
||||
{
|
||||
$msg=$langs->trans($msg);
|
||||
if (empty($msg)) continue;
|
||||
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
||||
{
|
||||
$out.="<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;
|
||||
|
||||
@@ -16,7 +16,10 @@ Website=Web site
|
||||
AddPage=Add page
|
||||
Page=Page
|
||||
PreviewOfSiteNotYetAvailable=Preview of your website <strong>%s</strong> not yet available. You must first add a page.
|
||||
PageDeleted=Page %s of website %s deleted
|
||||
RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this.
|
||||
PageDeleted=Page '%s' of website %s deleted
|
||||
PageAdded=Page '%s' added
|
||||
ViewSiteInNewTab=View site in new tab
|
||||
ViewPageInNewTab=View page in new tab
|
||||
SetAsHomePage=Set as Home page
|
||||
RealURL=Real URL
|
||||
@@ -48,8 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$error=0;
|
||||
$website=GETPOST('website', 'alpha');
|
||||
$page=GETPOST('page', 'alpha');
|
||||
$pageid=GETPOST('pageid', 'alpha');
|
||||
$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha');
|
||||
|
||||
$accessallowed = 1;
|
||||
$type='';
|
||||
@@ -81,13 +80,23 @@ if (empty($pageid))
|
||||
$pageid=$firstrep->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pageid))
|
||||
{
|
||||
$langs->load("website");
|
||||
print $langs->trans("PreviewOfSiteNotYetAvailable");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Security: Delete string ../ into $original_file
|
||||
global $dolibarr_main_data_root;
|
||||
|
||||
if ($pageid == 'css')
|
||||
{
|
||||
header('Content-type: text/css');
|
||||
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
|
||||
//if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
|
||||
//else
|
||||
header('Cache-Control: no-cache');
|
||||
$original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css';
|
||||
}
|
||||
else
|
||||
@@ -127,7 +136,9 @@ $original_file_osencoded=dol_osencode($original_file); // New file name encoded
|
||||
// This test if file exists should be useless. We keep it to find bug more easily
|
||||
if (! file_exists($original_file_osencoded))
|
||||
{
|
||||
dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
|
||||
$langs->load("website");
|
||||
print $langs->trans("RequestedPageHasNoContentYet", $pageid);
|
||||
//dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,15 +253,16 @@ class WebsitePage extends CommonObject
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit limit
|
||||
* @param int $offset Offset
|
||||
* @param array $filter Filter array
|
||||
* @param string $filtermode Filter mode (AND or OR)
|
||||
* @return array|int int <0 if KO, array of pages if OK
|
||||
* @param string $websiteid Web site
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit limit
|
||||
* @param int $offset Offset
|
||||
* @param array $filter Filter array
|
||||
* @param string $filtermode Filter mode (AND or OR)
|
||||
* @return array|int int <0 if KO, array of pages if OK
|
||||
*/
|
||||
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
|
||||
public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@@ -280,14 +281,15 @@ class WebsitePage extends CommonObject
|
||||
$sql .= " t.date_modification,";
|
||||
$sql .= " t.tms";
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
||||
$sql .= ' WHERE t.fk_website = '.$websiteid;
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key=='t.rowid' || $key=='t.fk_website') {
|
||||
$sqlwhere [] = $key . '='. $value;
|
||||
$sqlwhere[] = $key . '='. $value;
|
||||
} else {
|
||||
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,11 @@ $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
|
||||
$filecss=$pathofwebsite.'/styles.css';
|
||||
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -162,7 +167,7 @@ if ($action == 'add')
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("PageAdded"), null, 'mesgs');
|
||||
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
@@ -475,6 +480,9 @@ if (count($object->records) > 0)
|
||||
|
||||
if ($website)
|
||||
{
|
||||
print ' - '.$langs->trans("RealURL").' ';
|
||||
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website;
|
||||
print '<input type="text" name="realurl" value="'.$realurl.'"> ';
|
||||
print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
@@ -508,7 +516,9 @@ if (count($object->records) > 0)
|
||||
{
|
||||
print '</div>';
|
||||
|
||||
$array=$objectpage->fetchAll('','',0,0,array('t.fk_website'=>$object->id));
|
||||
$array=$objectpage->fetchAll($object->id);
|
||||
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
|
||||
$atleastonepage=(is_array($array) && count($array) > 0);
|
||||
|
||||
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
|
||||
print '<div class="websiteselection">';
|
||||
@@ -517,30 +527,33 @@ if (count($object->records) > 0)
|
||||
print '<div class="websiteselection">';
|
||||
$out='';
|
||||
$out.='<select name="pageid">';
|
||||
if (is_array($array) && count($array) > 0)
|
||||
if ($atleastonepage)
|
||||
{
|
||||
foreach($array as $key => $valpage)
|
||||
{
|
||||
if (empty($pageid) && $action != 'create') $pageid=$valpage->id;
|
||||
foreach($array as $key => $valpage)
|
||||
{
|
||||
if (empty($pageid) && $action != 'create') $pageid=$valpage->id;
|
||||
|
||||
$out.='<option value="'.$key.'"';
|
||||
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
|
||||
$out.='>';
|
||||
$out.=$valpage->title;
|
||||
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
|
||||
$out.='</option>';
|
||||
}
|
||||
$out.='<option value="'.$key.'"';
|
||||
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
|
||||
$out.='>';
|
||||
$out.=$valpage->title;
|
||||
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
|
||||
$out.='</option>';
|
||||
}
|
||||
}
|
||||
else $out.='<option value="-1"> </option>';
|
||||
$out.='</select>';
|
||||
print $out;
|
||||
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
|
||||
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'">';
|
||||
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
||||
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
||||
//print $form->selectarray('page', $array);
|
||||
|
||||
if ($website && $pageid > 0)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'&page='.$pageid.'" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>';
|
||||
print ' - '.$langs->trans("RealURL").' ';
|
||||
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
|
||||
print '<input type="text" name="realurl" value="'.$realurl.'"> ';
|
||||
print '<a href="'.$realurl.'" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
Reference in New Issue
Block a user