diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ce7c7c0143691..092ded571114c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -103,12 +103,13 @@ function dolWebsiteOutput($content) $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 - // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor') - if (defined('USEDOLIBARREDITOR')) + if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor { - // Do nothing + // We remove the part of content + $content = preg_replace('/.*<\/head>/ims', '', $content); + } - elseif (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr server + elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server { global $website; @@ -142,7 +143,7 @@ function dolWebsiteOutput($content) // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); } - else // REPLACEMENT OF LINKS When page called from virtual host + else // REPLACEMENT OF LINKS When page called from virtual host { $symlinktomediaexists=1; diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index bc28ad44aa12b..c52cd90dc1771 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -74,3 +74,7 @@ ALTER TABLE llx_societe ADD COLUMN twitter varchar(255) after skype; ALTER TABLE llx_societe ADD COLUMN facebook varchar(255) after skype; ALTER TABLE llx_socpeople ADD COLUMN twitter varchar(255) after skype; ALTER TABLE llx_socpeople ADD COLUMN facebook varchar(255) after skype; + + +ALTER TABLE llx_website CHANGE COLUMN fk_user_create fk_user_creat integer; +ALTER TABLE llx_website_page CHANGE COLUMN fk_user_create fk_user_creat integer; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index dd35116a91f63..5b6a88c88da68 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -27,9 +27,9 @@ CREATE TABLE llx_website status integer DEFAULT 1, fk_default_home integer, virtualhost varchar(255), - fk_user_create integer, - fk_user_modif integer, - date_creation datetime, - tms timestamp, - import_key varchar(14) -- import key + fk_user_creat integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp, + import_key varchar(14) -- import key ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index c795fa254dc59..3c872f00dacb7 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -32,10 +32,10 @@ CREATE TABLE llx_website_page htmlheader text, content mediumtext, -- text is not enough in size status integer DEFAULT 1, - grabbed_from varchar(255), - fk_user_create integer, - fk_user_modif integer, - date_creation datetime, - tms timestamp, - import_key varchar(14) -- import key + grabbed_from varchar(255), + fk_user_creat integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp, + import_key varchar(14) -- import key ) ENGINE=innodb; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 5852f201f1fa3..70926a2ce5c52 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1,10 +1,9 @@ +/* Copyright (C) 2007-2018 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Frédéric France - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,7 +157,7 @@ public function create(User $user, $notrigger = false) $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'fk_user_create,'; + $sql.= 'fk_user_creat,'; $sql.= 'date_creation,'; $sql.= 'tms'; $sql .= ') VALUES ('; @@ -168,7 +167,7 @@ public function create(User $user, $notrigger = false) $sql .= ' '.(! isset($this->status)?'1':$this->status).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->virtualhost)?'NULL':"'".$this->db->escape($this->virtualhost)."'").","; - $sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).','; + $sql .= ' '.(! isset($this->fk_user_creat)?$user->id:$this->fk_user_creat).','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").","; $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_creation)."'"); $sql .= ')'; @@ -227,7 +226,7 @@ public function fetch($id, $ref = null) $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -253,7 +252,7 @@ public function fetch($id, $ref = null) $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); @@ -317,7 +316,7 @@ public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, arra $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -357,7 +356,7 @@ public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, arra $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_modification = $this->db->jdate($obj->date_modification); @@ -770,7 +769,7 @@ public function initAsSpecimen() $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; - $this->fk_user_create = $user->id; + $this->fk_user_creat = $user->id; $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); $this->tms = dol_now(); diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index ff4355e1c12f2..97aba5e6ac24e 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -1,9 +1,8 @@ +/* Copyright (C) 2007-2018 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,8 +91,8 @@ class WebsitePage extends CommonObject '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'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), - //'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), - //'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1), ); @@ -159,7 +158,7 @@ public function fetch($id, $website_id = null, $page = null, $aliasalt = null) $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level @@ -202,7 +201,7 @@ public function fetch($id, $website_id = null, $page = null, $aliasalt = null) $this->grabbed_from = $obj->grabbed_from; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; } $this->db->free($resql); @@ -255,7 +254,7 @@ public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $of $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; $sql .= ' WHERE t.fk_website = '.$websiteid; @@ -271,11 +270,11 @@ public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $of } } if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield,$sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit, $offset); @@ -305,7 +304,7 @@ public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $of $record->grabbed_from = $obj->grabbed_from; $record->date_creation = $this->db->jdate($obj->date_creation); $record->date_modification = $this->db->jdate($obj->date_modification); - $record->fk_user_create = $obj->fk_user_create; + $record->fk_user_creat = $obj->fk_user_creat; $record->fk_user_modif = $obj->fk_user_modif; //var_dump($record->id); $records[$record->id] = $record; @@ -401,7 +400,7 @@ public function createFromClone(User $user, $fromid, $newref, $newlang='', $istr $object->ref = $newref; $object->pageurl = $newref; $object->aliasalt = ''; - $object->fk_user_create = $user->id; + $object->fk_user_creat = $user->id; $object->title = ($keeptitleunchanged ? '' : $langs->trans("CopyOf").' ').$object->title; if (! empty($newlang)) $object->lang=$newlang; if ($istranslation) $object->fk_page = $fromid; @@ -555,6 +554,6 @@ public function initAsSpecimen() $this->grabbed_from = ''; $this->date_creation = $now - (24 * 30 * 3600); $this->date_modification = $now - (24 * 7 * 3600); - $this->fk_user_create = $user->id; + $this->fk_user_creat = $user->id; } } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f1363dec5146c..f7b592e8992ac 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -388,7 +388,7 @@ // Remove comments $tmp['content'] = removeHtmlComment($tmp['content']); - preg_match('/(.*)<\/head>/is', $tmp['content'], $reg); + preg_match('/(.*)<\/head>/ims', $tmp['content'], $reg); $head = $reg[1]; $objectpage->type_container = 'page'; @@ -1327,7 +1327,7 @@ $objectpage->content = GETPOST('PAGE_CONTENT','none'); // Clean data. We remove all the head section. - $objectpage->content = preg_replace('/.*<\/head>/s', '', $objectpage->content); + $objectpage->content = preg_replace('/.*<\/head>/ims', '', $objectpage->content); /* $objectpage->content = preg_replace('//s', '', $objectpage->content); */ @@ -1690,7 +1690,8 @@ print ''; - // Toolbar for website + // Toolbar for websites + print '
'; if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') @@ -1790,7 +1791,7 @@ $out.=''; @@ -2665,8 +2666,8 @@ // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, // so editable will be available only from container created from scratch - //$out.='
grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; - $out.='
'."\n"; + //$out.='
grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; + $out.='
'."\n"; $newcontent = $objectpage->content;