Work on new management for website module

This commit is contained in:
Laurent Destailleur 2018-09-25 15:00:37 +02:00
parent b4b6e900f9
commit e6be047178
7 changed files with 47 additions and 43 deletions

View File

@ -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 <head> part of content
$content = preg_replace('/<head>.*<\/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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,10 +1,9 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* 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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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 @@ class Website extends CommonObject
$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();

View File

@ -1,9 +1,8 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* 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 @@ class WebsitePage extends CommonObject
$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 @@ class WebsitePage extends CommonObject
$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 @@ class WebsitePage extends CommonObject
$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 @@ class WebsitePage extends CommonObject
}
}
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 @@ class WebsitePage extends CommonObject
$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 @@ class WebsitePage extends CommonObject
$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 @@ class WebsitePage extends CommonObject
$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;
}
}

View File

@ -388,7 +388,7 @@ if ($action == 'addcontainer')
// Remove comments
$tmp['content'] = removeHtmlComment($tmp['content']);
preg_match('/<head>(.*)<\/head>/is', $tmp['content'], $reg);
preg_match('/<head>(.*)<\/head>/ims', $tmp['content'], $reg);
$head = $reg[1];
$objectpage->type_container = 'page';
@ -1327,7 +1327,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$objectpage->content = GETPOST('PAGE_CONTENT','none');
// Clean data. We remove all the head section.
$objectpage->content = preg_replace('/<head>.*<\/head>/s', '', $objectpage->content);
$objectpage->content = preg_replace('/<head>.*<\/head>/ims', '', $objectpage->content);
/* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
@ -1690,7 +1690,8 @@ if (count($object->records) > 0) // There is at least one web site
print '</div>';
// Toolbar for website
// Toolbar for websites
print '<div class="websitetools">';
if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')
@ -1790,7 +1791,7 @@ if (count($object->records) > 0) // There is at least one web site
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.='['.$valpage->type_container.' '.$valpage->id.'] ';
$out.='['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] ';
$out.=$valpage->pageurl.' - '.$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
@ -2665,8 +2666,8 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
// 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.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n";
$out.='<div id="bodywebsite" class="bodywebsite">'."\n";
//$out.='<div id="divbodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n";
$out.='<div id="divbodywebsite" class="bodywebsite">'."\n";
$newcontent = $objectpage->content;