';
-print '| '.$langs->trans("DeStockOnBill").' | ';
-print '';
+print ' | '.$langs->trans("DeStockOnBill").' | ';
+print '';
if (! empty($conf->facture->enabled))
{
print "';
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index d3e6964aea6..04b987192e1 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -476,7 +476,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
*/
public function createProductCombination(Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false)
{
- global $db, $user;
+ global $db, $user, $conf;
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
@@ -542,7 +542,11 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
$price_impact += (float) price2num($variations[$currcombattr][$currcombval]['price']);
}
- $newproduct->ref .= '_'.$prodattrval->ref;
+ if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
+ $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref;
+ } else {
+ $newproduct->ref .= '_'.$prodattrval->ref;
+ }
//The first one should not contain a linebreak
if ($newproduct->description) {
@@ -660,4 +664,4 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
return 1;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php
index 756d927aed9..ae10398795c 100644
--- a/htdocs/websites/class/websitepage.class.php
+++ b/htdocs/websites/class/websitepage.class.php
@@ -52,6 +52,7 @@ class WebsitePage extends CommonObject
public $title;
public $description;
public $keywords;
+ public $htmlheader;
public $content;
public $status;
public $date_creation;
@@ -67,11 +68,12 @@ class WebsitePage extends CommonObject
'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
- 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
- 'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
+ 'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
//'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'),
'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'),
+ 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0),
+ 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0),
'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
@@ -126,6 +128,7 @@ class WebsitePage extends CommonObject
$sql .= " t.title,";
$sql .= " t.description,";
$sql .= " t.keywords,";
+ $sql .= " t.htmlheader,";
$sql .= " t.content,";
$sql .= " t.lang,";
$sql .= " t.fk_page,";
@@ -162,6 +165,7 @@ class WebsitePage extends CommonObject
$this->title = $obj->title;
$this->description = $obj->description;
$this->keywords = $obj->keywords;
+ $this->htmlheader = $obj->htmlheader;
$this->content = $obj->content;
$this->lang = $obj->lang;
$this->fk_page = $obj->fk_page;
@@ -210,6 +214,7 @@ class WebsitePage extends CommonObject
$sql .= " t.title,";
$sql .= " t.description,";
$sql .= " t.keywords,";
+ $sql .= " t.htmlheader,";
$sql .= " t.content,";
$sql .= " t.lang,";
$sql .= " t.fk_page,";
@@ -255,6 +260,7 @@ class WebsitePage extends CommonObject
$record->title = $obj->title;
$record->description = $obj->description;
$record->keywords = $obj->keywords;
+ $record->htmlheader = $obj->htmlheader;
$record->content = $obj->content;
$record->lang = $obj->lang;
$record->fk_page = $obj->fk_page;
@@ -469,6 +475,7 @@ class WebsitePage extends CommonObject
$this->title = 'My Page';
$this->description = 'This is my page';
$this->keywords = 'keyword1, keyword2';
+ $this->htmlheader = '';
$this->content = 'This is a html content';
$this->status = '';
$this->grabbed_from = '';
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 35731bc3bb0..95ef8f37948 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -94,6 +94,7 @@ $pageid=GETPOST('pageid', 'int');
$pageref=GETPOST('pageref', 'aZ09');
$action=GETPOST('action','alpha');
+
if (GETPOST('delete')) { $action='delete'; }
if (GETPOST('preview')) $action='preview';
if (GETPOST('createsite')) { $action='createsite'; }
@@ -246,7 +247,11 @@ if ($action == 'add')
$urltograbwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograbwithoutdomain);
$objectpage->pageurl = basename($urltograbwithoutdomain);
- if (empty($objectpage->pageurl)) $objectpage->pageurl='home';
+ if (empty($objectpage->pageurl))
+ {
+ $tmpdomain = getDomainFromURL($urltograb);
+ $objectpage->pageurl='home'.$tmpdomain;
+ }
if (preg_match('/(.*)<\/title>/ims', $head, $regtmp))
{
@@ -270,16 +275,62 @@ if ($action == 'add')
$objectpage->content = preg_replace('/^.*]*>/ims', '', $objectpage->content);
$objectpage->content = preg_replace('/<\/body[^>]*>.*$/ims', '', $objectpage->content);
+
+ // Now loop to fetch all css files. Include them inline into header of page
+ // TODO...
+
+
+ $tmp = $objectpage->content;
+
+ // Now loop to fetch all images
+ preg_match_all('/ "]+)"([^>]*)>/i', $objectpage->content, $regs);
+ foreach ($regs[0] as $key => $val)
+ {
+ $urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
+ $linkwithoutdomain = $regs[2][$key];
+ $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
+ if (preg_match('/^http/', $regs[2][$key]))
+ {
+ $urltograbbis = $regs[2][$key];
+ $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
+ $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
+ }
+
+ $tmpgeturl = getURLContent($urltograbbis);
+ if ($tmpgeturl['curl_error_no'])
+ {
+ $error++;
+ setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
+ $action='create';
+ }
+ else
+ {
+ dol_mkdir(dirname($filetosave));
+
+ $fp = fopen($filetosave, "w");
+ fputs($fp, $tmpgeturl['content']);
+ fclose($fp);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+ }
+
+ $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
+ $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', ' ', $tmp);
+ }
+
+ //print dol_escape_htmltag($tmp);exit;
+ $objectpage->content = $tmp;
+
$objectpage->grabbed_from = $urltograb;
}
}
else
{
- $objectpage->title = GETPOST('WEBSITE_TITLE');
- $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
- $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
- $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS');
- $objectpage->lang = GETPOST('WEBSITE_LANG');
+ $objectpage->title = GETPOST('WEBSITE_TITLE','alpha');
+ $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha');
+ $objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha');
+ $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha');
+ $objectpage->lang = GETPOST('WEBSITE_LANG','alpha');
}
if (! $error)
@@ -312,6 +363,33 @@ if ($action == 'add')
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
+ }
+ if (! $error)
+ {
+ if (! empty($objectpage->content))
+ {
+ $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
+ $filetpl=$pathofwebsite.'/page'.$objectpage->id.'.tpl.php';
+
+ // Save page alias
+ $result=dolSavePageAlias($filealias, $object, $objectpage);
+ if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
+
+ // Save page of content
+ $result=dolSavePageContent($filetpl, $object, $objectpage);
+ if ($result)
+ {
+ setEventMessages($langs->trans("Saved"), null, 'mesgs');
+ //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
+ //exit;
+ }
+ else
+ {
+ setEventMessages('Failed to write file '.$filetpl, null, 'errors');
+ //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
+ //exit;
+ }
+ }
}
if (! $error)
{
@@ -326,8 +404,36 @@ if ($action == 'add')
if (! $error)
{
- $action = 'preview';
- $pageid = $objectpage->id;
+ $pageid = $objectpage->id;
+
+ // To generate the CSS, robot and htmlheader file.
+
+ if (! dol_is_file($filehtmlheader))
+ {
+ // TODO use header of page for common header ?
+ $htmlheadercontent = "";
+ $result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
+ }
+
+ if (! dol_is_file($filecss))
+ {
+ $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; }'";
+ $result=dolSaveCssFile($filecss, $csscontent);
+ }
+
+ if (! dol_is_file($filerobot))
+ {
+ $robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
+ $result=dolSaveRobotFile($filerobot, $robotcontent);
+ }
+
+ if (! dol_is_file($filehtaccess))
+ {
+ $htaccesscontent = "# Order allow,deny\n# Deny from all";
+ $result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
+ }
+
+ $action = 'preview';
}
}
@@ -392,7 +498,7 @@ if ($action == 'updatecss')
// $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page
$htmlheadercontent.= "// END PHP ?>\n";*/
- $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER'));
+ $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER', 'none'));
/*$htmlheadercontent.= "\n".'global->MAIN_UMASK))
- @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- $error++;
- setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
- }
// Css file
$csscontent ='';
@@ -425,7 +521,7 @@ if ($action == 'updatecss')
$csscontent.= "header('Content-type: text/css');\n";
$csscontent.= "// END PHP ?>\n";
- $csscontent.= GETPOST('WEBSITE_CSS_INLINE');
+ $csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none');
$csscontent.= "\n".'\n";*/
- $robotcontent.= GETPOST('WEBSITE_ROBOT');
+ $robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
/*$robotcontent.= "\n".'\n";*/
- $htaccesscontent.= GETPOST('WEBSITE_HTACCESS');
+ $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
/*$robotcontent.= "\n".'old_object = clone $objectpage;
- $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
- $objectpage->title = GETPOST('WEBSITE_TITLE');
- $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
- $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS');
- $objectpage->lang = GETPOST('WEBSITE_LANG');
+ $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
+ $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha');
+ $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
+ $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
+ $objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha');
$res = $objectpage->update($user);
if (! $res > 0)
@@ -1446,6 +1542,12 @@ if ($action == 'editmeta' || $action == 'create')
if ($action != 'create')
{
+ print ' |