Work on website
This commit is contained in:
parent
d484383467
commit
25dfa0c5b9
@ -2775,7 +2775,7 @@ function dol_print_error($db='',$error='',$errors=null)
|
|||||||
|
|
||||||
foreach($errors as $msg)
|
foreach($errors as $msg)
|
||||||
{
|
{
|
||||||
$msg=$langs->trans($msg);
|
if (empty($msg)) continue;
|
||||||
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
if ($_SERVER['DOCUMENT_ROOT']) // Mode web
|
||||||
{
|
{
|
||||||
$out.="<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;
|
$out.="<b>".$langs->trans("Message").":</b> ".$msg."<br>\n" ;
|
||||||
|
|||||||
@ -16,7 +16,10 @@ Website=Web site
|
|||||||
AddPage=Add page
|
AddPage=Add page
|
||||||
Page=Page
|
Page=Page
|
||||||
PreviewOfSiteNotYetAvailable=Preview of your website <strong>%s</strong> not yet available. You must first add a 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
|
ViewSiteInNewTab=View site in new tab
|
||||||
ViewPageInNewTab=View page in new tab
|
ViewPageInNewTab=View page in new tab
|
||||||
SetAsHomePage=Set as Home page
|
SetAsHomePage=Set as Home page
|
||||||
|
RealURL=Real URL
|
||||||
@ -48,8 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
$website=GETPOST('website', 'alpha');
|
$website=GETPOST('website', 'alpha');
|
||||||
$page=GETPOST('page', 'alpha');
|
$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha');
|
||||||
$pageid=GETPOST('pageid', 'alpha');
|
|
||||||
|
|
||||||
$accessallowed = 1;
|
$accessallowed = 1;
|
||||||
$type='';
|
$type='';
|
||||||
@ -81,13 +80,23 @@ if (empty($pageid))
|
|||||||
$pageid=$firstrep->id;
|
$pageid=$firstrep->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (empty($pageid))
|
||||||
|
{
|
||||||
|
$langs->load("website");
|
||||||
|
print $langs->trans("PreviewOfSiteNotYetAvailable");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// Security: Delete string ../ into $original_file
|
// Security: Delete string ../ into $original_file
|
||||||
global $dolibarr_main_data_root;
|
global $dolibarr_main_data_root;
|
||||||
|
|
||||||
if ($pageid == 'css')
|
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';
|
$original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css';
|
||||||
}
|
}
|
||||||
else
|
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
|
// This test if file exists should be useless. We keep it to find bug more easily
|
||||||
if (! file_exists($original_file_osencoded))
|
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;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -253,15 +253,16 @@ class WebsitePage extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
* @param string $sortorder Sort Order
|
* @param string $websiteid Web site
|
||||||
* @param string $sortfield Sort field
|
* @param string $sortorder Sort Order
|
||||||
* @param int $limit limit
|
* @param string $sortfield Sort field
|
||||||
* @param int $offset Offset
|
* @param int $limit limit
|
||||||
* @param array $filter Filter array
|
* @param int $offset Offset
|
||||||
* @param string $filtermode Filter mode (AND or OR)
|
* @param array $filter Filter array
|
||||||
* @return array|int int <0 if KO, array of pages if OK
|
* @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);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
@ -280,14 +281,15 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= " t.date_modification,";
|
$sql .= " t.date_modification,";
|
||||||
$sql .= " t.tms";
|
$sql .= " t.tms";
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
||||||
|
$sql .= ' WHERE t.fk_website = '.$websiteid;
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array();
|
$sqlwhere = array();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
foreach ($filter as $key => $value) {
|
foreach ($filter as $key => $value) {
|
||||||
if ($key=='t.rowid' || $key=='t.fk_website') {
|
if ($key=='t.rowid' || $key=='t.fk_website') {
|
||||||
$sqlwhere [] = $key . '='. $value;
|
$sqlwhere[] = $key . '='. $value;
|
||||||
} else {
|
} 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';
|
$filecss=$pathofwebsite.'/styles.css';
|
||||||
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
$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)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
setEventMessages($langs->trans("PageAdded"), null, 'mesgs');
|
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -475,6 +480,9 @@ if (count($object->records) > 0)
|
|||||||
|
|
||||||
if ($website)
|
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 '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';
|
||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -508,7 +516,9 @@ if (count($object->records) > 0)
|
|||||||
{
|
{
|
||||||
print '</div>';
|
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="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
|
||||||
print '<div class="websiteselection">';
|
print '<div class="websiteselection">';
|
||||||
@ -517,30 +527,33 @@ if (count($object->records) > 0)
|
|||||||
print '<div class="websiteselection">';
|
print '<div class="websiteselection">';
|
||||||
$out='';
|
$out='';
|
||||||
$out.='<select name="pageid">';
|
$out.='<select name="pageid">';
|
||||||
if (is_array($array) && count($array) > 0)
|
if ($atleastonepage)
|
||||||
{
|
{
|
||||||
foreach($array as $key => $valpage)
|
foreach($array as $key => $valpage)
|
||||||
{
|
{
|
||||||
if (empty($pageid) && $action != 'create') $pageid=$valpage->id;
|
if (empty($pageid) && $action != 'create') $pageid=$valpage->id;
|
||||||
|
|
||||||
$out.='<option value="'.$key.'"';
|
$out.='<option value="'.$key.'"';
|
||||||
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
|
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
|
||||||
$out.='>';
|
$out.='>';
|
||||||
$out.=$valpage->title;
|
$out.=$valpage->title;
|
||||||
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
|
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
|
||||||
$out.='</option>';
|
$out.='</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $out.='<option value="-1"> </option>';
|
else $out.='<option value="-1"> </option>';
|
||||||
$out.='</select>';
|
$out.='</select>';
|
||||||
print $out;
|
print $out;
|
||||||
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans("Refresh").'">';
|
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").'">';
|
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
||||||
//print $form->selectarray('page', $array);
|
//print $form->selectarray('page', $array);
|
||||||
|
|
||||||
if ($website && $pageid > 0)
|
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>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user