Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop

This commit is contained in:
Darkjeff 2017-07-03 06:19:16 +02:00
commit 535bd4dcb8
11 changed files with 210 additions and 125 deletions

View File

@ -857,6 +857,7 @@ class DoliDBMysqli extends DoliDB
* Return charset used to store data in current database (same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";)
*
* @return string Charset
* @see getDefaultCollationDatabase
*/
function getDefaultCharacterSetDatabase()
{
@ -867,7 +868,9 @@ class DoliDBMysqli extends DoliDB
return $this->forcecharset;
}
$liste=$this->fetch_array($resql);
return $liste['Value'];
$tmpval = $liste['Value'];
return $tmpval;
}
/**
@ -900,6 +903,7 @@ class DoliDBMysqli extends DoliDB
* Return collation used in current database
*
* @return string Collation value
* @see getDefaultCharacterSetDatabase
*/
function getDefaultCollationDatabase()
{
@ -910,7 +914,9 @@ class DoliDBMysqli extends DoliDB
return $this->forcecollate;
}
$liste=$this->fetch_array($resql);
return $liste['Value'];
$tmpval = $liste['Value'];
return $tmpval;
}
/**

View File

@ -25,7 +25,22 @@
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_supplier_proposaldet CHANGE COLUMN fk_askpricesupplier fk_supplier_proposal integer NOT NULL;
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00';
-- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN datefin datetime NULL;
-- To remove a default value for date that is not valid when field is not null
-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime DEFAULT NULL;
-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime NOT NULL;
-- Clean corrupted values for tms
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
@ -331,6 +346,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL;
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL;
UPDATE TABLE llx_contrat set ref = rowid where ref is null or ref = '';
create table llx_payment_various
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
@ -501,7 +518,7 @@ CREATE TABLE llx_blockedlog_authority
ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature);
-- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid
-- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid;
UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur';
UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client';

View File

@ -13,12 +13,17 @@
-- flush privileges;
-- Requests to change character set and collation of a varchar column.
-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+)
-- Request to change default pagecode + colation of database
-- ALTER DATABASE name_of_database CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Request to change default pagecode + colation of table
-- ALTER TABLE name_of_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Request to change character set and collation of a varchar column.
-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+)
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci;
-- You can check with 'show full columns from llx_accounting_account';
-- You can check with 'show full columns from mytablename';

View File

@ -16,4 +16,5 @@
--
-- ============================================================================
ALTER TABLE llx_product_attribute ADD CONSTRAINT unique_ref UNIQUE (ref);
ALTER TABLE llx_product_attribute ADD UNIQUE INDEX uk_product_attribute_ref (ref);

View File

@ -78,6 +78,7 @@ print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(G
print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'<br>'."\n";
print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'<br>'."\n";
print 'Option force_disable_of_modules_not_found (0 or \'test\' or \'confirmed\') is '.(GETPOST('force_disable_of_modules_not_found','alpha')?GETPOST('force_disable_of_modules_not_found','alpha'):'0').'<br>'."\n";
print 'Option force_utf8_on_tables, for mysql/mariadb only(0 or \'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables','alpha')?GETPOST('force_utf8_on_tables','alpha'):'0').'<br>'."\n";
print '<br>';
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
@ -890,6 +891,35 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
// clean_old_module_entries: Clean data into const when files of module were removed without being
// clean_linked_elements: Check and clean linked elements
if ($ok && GETPOST('force_utf8_on_tables','alpha'))
{
print '<tr><td colspan="2"><br>*** Force page code and collation with utf8 (for mysql/mariadb only)</td></tr>';
if ($db->type == "mysql")
{
$listoftables = $db->DDLListTables($db->database_name);
foreach($listoftables as $table)
{
print '<tr><td colspan="2">';
print $table;
$sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci';
if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed')
{
$db->query($sql);
}
print '</td></tr>';
}
}
else
{
print '<tr><td colspan="2">Not available with database type '.$db->type.'</td></tr>';
}
}
print '</table>';

View File

@ -312,8 +312,11 @@ if (! $error && $db->connected)
// Define $defaultCharacterSet and $defaultDBSortingCollation
if (! $error && $db->connected)
{
if (!empty($db_create_database)) { // If we create database, we force default value
$defaultCharacterSet=$db->forcecharset;
if (!empty($db_create_database)) // If we create database, we force default value
{
// Default values come from the database handler
$defaultCharacterSet=$db->forcecharset;
$defaultDBSortingCollation=$db->forcecollate;
}
else // If already created, we take current value
@ -322,6 +325,14 @@ if (! $error && $db->connected)
$defaultDBSortingCollation=$db->getDefaultCollationDatabase();
}
// Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
// TODO Remove this when utf8mb4 is supported
if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci')
{
$defaultCharacterSet = 'utf8';
$defaultDBSortingCollation = 'utf8_unicode_ci';
}
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
$db_character_set=$defaultCharacterSet;

View File

@ -25,4 +25,5 @@ RealURL=Real URL
ViewWebsiteInProduction=View web site using home URLs
SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on <strong>%s</strong>, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server.
PreviewSiteServedByWebServer=Preview %s in a new tab.<br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong>
PreviewSiteServedByDolibarr=Preview %s in a new tab.<br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and clicking on the other preview button.
PreviewSiteServedByDolibarr=Preview %s in a new tab.<br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button.
NoPageYet=No pages yet

View File

@ -297,7 +297,7 @@ if ($action == 'charge')
}
$_SESSION["onlinetoken"] = $stripeToken;
$_SESSION["FinalPaymentAmt"] = $amount;
$_SESSION["Payment_Amount"] = $amount;
$_SESSION["currencyCodeType"] = $currency;
$_SESSION["paymentType"] = '';
$_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip

View File

@ -12,9 +12,10 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't ne
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
// If you don't need session management (can't be logged if no session used). You must also set
// NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN,
// NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN
// Disable module with GETPOST('disablemodules') won't work. Variable 'dol_...' will not be set.
// $_SESSION are then simple vars if sessions are not active.
// TODO We can close session with session_write_close() as soon as we just need read access.
if (! defined("NOSESSION")) define("NOSESSION",'1');
define('REQUIRE_JQUERY_MULTISELECT','select2');

View File

@ -193,7 +193,6 @@ class WebsitePage extends CommonObject
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.fk_website,";
$sql .= " t.pageurl,";
$sql .= " t.title,";
@ -203,7 +202,6 @@ class WebsitePage extends CommonObject
$sql .= " t.status,";
$sql .= " t.date_creation,";
$sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
$sql .= ' WHERE 1 = 1';
@ -214,7 +212,7 @@ class WebsitePage extends CommonObject
$sql .= ' AND t.rowid = ' . $id;
}
$sql .= $this->db->plimit(1);
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
@ -278,7 +276,7 @@ class WebsitePage extends CommonObject
$sql .= " t.date_creation,";
$sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid;
$sql .= ' WHERE t.fk_website = '.$websiteid;
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
@ -399,9 +397,9 @@ class WebsitePage extends CommonObject
if ($this->old_object->pageurl != $this->pageurl)
{
dol_syslog("The alias was changed, we must rename/recreate the page file into document");
}
if (!$error && !$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
@ -628,7 +626,7 @@ class WebsitePage extends CommonObject
$this->id = 0;
$now=dol_now();
$this->fk_website = '';
$this->pageurl = '';
$this->title = 'My Page';

View File

@ -49,7 +49,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
print '<body id="mainbody">';
// top menu and left menu area
if (empty($conf->dol_hide_topmenu))
{
@ -145,7 +145,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
*/
if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
if (GETPOST('refreshpage')) $action='preview';
if (GETPOST('refreshpage')) $action='preview';
// Add page
@ -160,10 +160,17 @@ if ($action == 'add')
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
if (empty($objectpage->title))
if (empty($objectpage->pageurl))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++;
$action='create';
}
if (empty($objectpage->title))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors');
$error++;
$action='create';
}
if (! $error)
@ -185,9 +192,12 @@ if ($action == 'add')
{
$db->rollback();
}
$action = 'preview';
$id = $objectpage->id;
if (! $error)
{
$action = 'preview';
$id = $objectpage->id;
}
}
// Update page
@ -212,7 +222,7 @@ if ($action == 'delete')
{
$db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit;
}
@ -246,7 +256,7 @@ if ($action == 'updatecss')
$error++;
$db->rollback();
}*/
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
$csscontent.= '<!-- File generated to wrap the css file - DO NOT MODIFY - It is just a copy of database css content -->'."\n";
$csscontent.= '<?php '."\n";
@ -254,25 +264,25 @@ if ($action == 'updatecss')
$csscontent.= "?>"."\n";
$csscontent.= '<!-- END -->'."\n";
$csscontent.= GETPOST('WEBSITE_CSS_INLINE');
dol_syslog("Save file css into ".$filecss);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filecss, null, 'errors');
}
if (! $error)
{
setEventMessages($langs->trans("Saved"), null, 'mesgs');
}
$action='preview';
}
@ -289,11 +299,11 @@ if ($action == 'setashome')
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
if (! $error)
{
$db->commit();
// Generate the index.php page to be the home page
//-------------------------------------------------
dol_mkdir($pathofwebsite);
@ -306,10 +316,10 @@ if ($action == 'setashome')
$result = file_put_contents($fileindex, $indexcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs');
else setEventMessages('Failed to write file '.$fileindex, null, 'errors');
$action='preview';
}
else
@ -330,7 +340,7 @@ if ($action == 'updatemeta')
if ($res > 0)
{
$objectpage->old_object = clone $objectpage;
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
@ -353,11 +363,11 @@ if ($action == 'updatemeta')
dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
@ -365,17 +375,17 @@ if ($action == 'updatemeta')
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Now generate the alias.php page
if (! empty($fileoldalias))
{
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
dol_delete_file($fileoldalias);
}
$aliascontent = '<?php'."\n";
$aliascontent.= '// File generated to wrap the page - DO NOT MODIFY - It is just an include'."\n";
$aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n";
@ -383,15 +393,15 @@ if ($action == 'updatemeta')
$result = file_put_contents($filealias, $aliascontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
// Now create the .tpl file (duplicate code with actions updatecontent but we need this to save new header)
dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
dol_delete_file($filetpl);
$tplcontent ='';
$tplcontent.= '<?php require "./master.inc.php"; ?>'."\n";
$tplcontent.= '<html>'."\n";
@ -407,7 +417,7 @@ if ($action == 'updatemeta')
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
$tplcontent.= '</header>'."\n";
$tplcontent.= '<body>'."\n";
$tplcontent.= $objectpage->content."\n";
$tplcontent.= '</body>'."\n";
@ -415,7 +425,7 @@ if ($action == 'updatemeta')
$result = file_put_contents($filetpl, $tplcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
if ($result)
{
setEventMessages($langs->trans("Saved"), null, 'mesgs');
@ -423,7 +433,7 @@ if ($action == 'updatemeta')
//exit;
}
else setEventMessages('Failed to write file '.$filetpl, null, 'errors');
$action='preview';
}
else
@ -447,55 +457,60 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$object->virtualhost = GETPOST('previewsite', 'alpha');
$object->update($user);
}*/
$objectpage->fk_website = $object->id;
if ($pageid > 0)
if ($pageid > 0)
{
$res = $objectpage->fetch($pageid);
}
else
else
{
$res = $objectpage->fetch($object->fk_default_home);
if (! $res > 0)
$res=0;
if ($object->fk_default_home > 0)
{
$res = $objectpage->fetch(0, $object->fk_website);
$res = $objectpage->fetch($object->fk_default_home);
}
if (! ($res > 0))
{
$res = $objectpage->fetch(0, $object->id);
}
}
if ($res > 0)
{
if ($action == 'updatecontent')
{
$db->begin();
$objectpage->content = GETPOST('PAGE_CONTENT');
// Clean data. We remove all the head section.
$objectpage->content = preg_replace('/<head.*<\/head>/s', '', $objectpage->content);
/* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
$res = $objectpage->update($user);
if ($res < 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
if (! $error)
{
$db->commit();
$filemaster=$pathofwebsite.'/master.inc.php';
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
@ -503,17 +518,17 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Now generate the alias.php page
if (! empty($fileoldalias))
{
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
dol_delete_file($fileoldalias);
}
$aliascontent = '<?php'."\n";
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a copy of database page content\n";
$aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n";
@ -521,13 +536,13 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$result = file_put_contents($filealias, $aliascontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
// Now create the .tpl file with code to be able to make dynamic changes
dol_delete_file($filetpl);
$tplcontent ='';
$tplcontent.= "<?php // BEGIN PHP\n";
$tplcontent.= "if (! defined('USEDOLIBARRSERVER')) { require './master.inc.php'; } // Not already loaded"."\n";
@ -546,29 +561,29 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website='.$website.'" type="text/css" />'."\n";
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
$tplcontent.= '</header>'."\n";
$tplcontent.= '<body>'."\n";
$tplcontent.= $objectpage->content."\n";
$tplcontent.= '</body>'."\n";
$tplcontent.= '<?php // BEGIN PHP'."\n";
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
$tplcontent.= "// END PHP ?>"."\n";
//var_dump($filetpl);exit;
//var_dump($filetpl);exit;
$result = file_put_contents($filetpl, $tplcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
if ($result)
{
setEventMessages($langs->trans("Saved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
else
else
{
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
@ -586,7 +601,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
}
else
{
dol_print_error($db, 'Page not found');
setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
}
}
@ -644,7 +659,7 @@ print '<div class="centpercent websitebar">';
if (count($object->records) > 0)
{
// ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': ';
print '</div>';
@ -678,20 +693,20 @@ if (count($object->records) > 0)
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
if ($website && $action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
print ' &nbsp; ';
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
}
print '</div>';
// Button for websites
@ -705,7 +720,7 @@ if (count($object->records) > 0)
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '</div>';
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
//if (! empty($object->virtualhost))
@ -714,7 +729,7 @@ if (count($object->records) > 0)
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
//}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>';
@ -726,12 +741,12 @@ if (count($object->records) > 0)
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
// ***** Part for pages
if ($website)
{
print '</div>';
@ -739,13 +754,13 @@ if (count($object->records) > 0)
$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 hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteselection">';
if ($action != 'add')
{
$out='';
@ -762,7 +777,7 @@ if (count($object->records) > 0)
}
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
@ -785,16 +800,16 @@ if (count($object->records) > 0)
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array);
if ($action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0)
{
print ' &nbsp; ';
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
@ -804,7 +819,7 @@ if (count($object->records) > 0)
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
}
}
print '</div>';
print '<div class="websiteselection">';
print '</div>';
@ -815,17 +830,17 @@ if (count($object->records) > 0)
{
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext);
print '</div>';
if (! empty($object->virtualhost))
{
$urlext=$virtualurl.'/'.$pagealias.'.php';
@ -839,12 +854,12 @@ if (count($object->records) > 0)
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
// 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','create')))
@ -853,7 +868,7 @@ if (count($object->records) > 0)
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
if ($action == 'preview')
@ -880,7 +895,7 @@ if (count($object->records) > 0)
},
context: document.body
});
jQuery("#previewsiteext").attr("href",newurl);
jQuery("#previewpageext").attr("href",newpage);
});
@ -917,8 +932,8 @@ if ($action == 'editcss')
$csscontent = @file_get_contents($filecss);
// Clean the php css file to remove php code and get only css part
$csscontent = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $csscontent);
$csscontent = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $csscontent);
dol_fiche_head();
print '<!-- Edit CSS -->'."\n";
@ -956,14 +971,14 @@ if ($action == 'editcss')
if ($action == 'editmeta' || $action == 'create')
{
print '<div class="fiche">';
print '<br>';
dol_fiche_head();
print '<!-- Edit Meta -->'."\n";
print '<table class="border" width="100%">';
if ($action != 'create')
{
print '<tr><td>';
@ -986,7 +1001,7 @@ if ($action == 'editmeta' || $action == 'create')
print '</td><td>';
print '<input type="text" class="flat" size="96" name="WEBSITE_PAGENAME" value="'.$pageurl.'">';
print '</td></tr>';
print '<tr><td>';
print $langs->trans('WEBSITE_TITLE');
print '</td><td>';
@ -1031,15 +1046,15 @@ if ($action == 'editcontent')
/*
* Editing global variables not related to a specific theme
*/
$csscontent = @file_get_contents($filecss);
$contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%');
$doleditor->Create(0, '', false);
@ -1056,23 +1071,23 @@ if ($action == 'preview')
$objectpage->fetch($pageid);
$out = "\n".'<!-- Page content '.$filetpl.' : Div with (CSS + Page content from database) -->'."\n";
$out.='<div id="websitecontent" class="websitecontent">'."\n";
$csscontent = @file_get_contents($filecss);
$out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$out.=$csscontent;
$out.='</style>'."\n";
$out.=$objectpage->content."\n";
$out.='</div>';
$out.= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n";
print $out;
/*file_put_contents($filetpl, $out);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
@ -1080,17 +1095,17 @@ if ($action == 'preview')
// Output file on browser
dol_syslog("index.php include $filetpl $filename content-type=$type");
$original_file_osencoded=dol_osencode($filetpl); // New file name encoded in OS encoding charset
// 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));
exit;
}
//include_once $original_file_osencoded;
*/
/*print '<iframe class="websiteiframenoborder centpercent" src="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'&pageid='.$pageid.'"/>';
print '</iframe>';*/
}