Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop
This commit is contained in:
commit
8454c30bbb
@ -73,7 +73,7 @@ $tablib[1] = "Websites";
|
||||
|
||||
// Requests to extract data
|
||||
$tabsql=array();
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.status FROM ".MAIN_DB_PREFIX."website as f";
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.status FROM ".MAIN_DB_PREFIX."website as f";
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort=array();
|
||||
@ -81,15 +81,15 @@ $tabsqlsort[1] ="ref ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[1] = "ref,description";
|
||||
$tabfield[1] = "ref,description,virtualhost";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[1] = "ref,description";
|
||||
$tabfieldvalue[1] = "ref,description,virtualhost";
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[1] = "ref,description,entity";
|
||||
$tabfieldinsert[1] = "ref,description,virtualhost,entity";
|
||||
|
||||
// Nom du rowid si le champ n'est pas de type autoincrement
|
||||
// Example: "" if id field is "rowid" and has autoincrement on
|
||||
@ -103,7 +103,7 @@ $tabcond[1] = (! empty($conf->websites->enabled));
|
||||
|
||||
// List of help for fields
|
||||
$tabhelp=array();
|
||||
$tabhelp[1] = array();
|
||||
$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/websites/<i>websiteref</i>'));
|
||||
|
||||
// List of check for fields (NOT USED YET)
|
||||
$tabfieldcheck=array();
|
||||
@ -126,12 +126,19 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha'))
|
||||
$ok=1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if (! isset($_POST[$value]) || $_POST[$value]=='') // Fields that are not mandatory
|
||||
if ((! isset($_POST[$value]) || $_POST[$value]=='')
|
||||
&& (! in_array($listfield[$f], array('virtualhost')))) // Fields that are not mandatory
|
||||
{
|
||||
$ok=0;
|
||||
$fieldnamekey=$listfield[$f];
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
|
||||
}
|
||||
if ($value == 'ref' && (preg_match('/[a-zA-Z0-9]/', $_POST[$value])))
|
||||
{
|
||||
$ok=0;
|
||||
$fieldnamekey=$listfield[$f];
|
||||
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
|
||||
@ -52,7 +52,7 @@ class DolEditor
|
||||
* @param string $content Content of WYSIWIG field
|
||||
* @param int $width Width in pixel of edit area (auto by default)
|
||||
* @param int $height Height in pixel of edit area (200px by default)
|
||||
* @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly')
|
||||
* @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly', 'ace').
|
||||
* @param string $toolbarlocation Where bar is stored :
|
||||
* 'In' each window has its own toolbar
|
||||
* 'Out:name' share toolbar into the div called 'name'
|
||||
@ -145,9 +145,10 @@ class DolEditor
|
||||
* @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only.
|
||||
* @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only.
|
||||
* @param string $titlecontent Show title content before editor area. Used by ACE editor only.
|
||||
* @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...)
|
||||
* @return void|string
|
||||
*/
|
||||
function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='')
|
||||
function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -254,21 +255,21 @@ class DolEditor
|
||||
if (preg_match('/^ace/', $this->tool))
|
||||
{
|
||||
$found=1;
|
||||
$format=(GETPOST('format','aZ09')?GETPOST('format','aZ09'):'php');
|
||||
$format=$option;
|
||||
|
||||
$out.= '<!-- Output Ace editor -->'."\n";
|
||||
$out.= "\n".'<!-- Output Ace editor -->'."\n";
|
||||
|
||||
if ($titlecontent)
|
||||
{
|
||||
$out.= '<div class="aceeditorstatusbar" id="statusBar">'.$titlecontent;
|
||||
$out.= ' - <a id="morelines" href="#" class="right morelines">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> ';
|
||||
$out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent;
|
||||
$out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> ';
|
||||
$out.= '</div>';
|
||||
$out.= '<script type="text/javascript" language="javascript">'."\n";
|
||||
$out.= 'jQuery(document).ready(function() {'."\n";
|
||||
$out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid");
|
||||
var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar
|
||||
var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar")); // Init status bar. Need lib ext-statusbar
|
||||
jQuery("#morelines").click(function() {
|
||||
var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar
|
||||
var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar
|
||||
jQuery(".morelines'.$this->htmlname.'").click(function() {
|
||||
console.log("We click on more lines");
|
||||
var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid");
|
||||
aceEditor.setOptions({ maxLines: 500 });
|
||||
@ -297,8 +298,8 @@ class DolEditor
|
||||
enableLiveAutocompletion: false, // the editor completes the statement while you are typing. Need lib ext-language_tools.js
|
||||
showPrintMargin: false, // hides the vertical limiting strip
|
||||
minLines: 10,
|
||||
maxLines: 34,
|
||||
fontSize: "110%" // ensures that the editor fits in the environment
|
||||
maxLines: '.(empty($this->height)?'34':(round($this->height/10))).',
|
||||
fontSize: "110%" // ensures that the editor fits in the environment
|
||||
});
|
||||
|
||||
// defines the style of the editor
|
||||
@ -311,10 +312,12 @@ class DolEditor
|
||||
|
||||
$out.= 'jQuery(document).ready(function() {
|
||||
jQuery("#savefile").click(function() {
|
||||
console.log("We click on savefile button");
|
||||
console.log("We click on savefile button for component '.$this->htmlname.'");
|
||||
var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid")
|
||||
console.log(aceEditor.getSession().getValue());
|
||||
jQuery("#'.$this->htmlname.'").val(aceEditor.getSession().getValue());
|
||||
if (strlen(jQuery("#'.$this->htmlname.'").html()) > 0) return true;
|
||||
else return false;
|
||||
/*if (jQuery("#'.$this->htmlname.'").html().length > 0) return true;
|
||||
else return false;*/
|
||||
});
|
||||
})';
|
||||
$out.= '</script>'."\n";
|
||||
|
||||
@ -29,4 +29,5 @@ ViewWebsiteInProduction=View web site using home URLs
|
||||
SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on <strong>%s</strong><br>then enter here the virtual hostname you have created, 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 click on the other preview button.
|
||||
VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined
|
||||
NoPageYet=No pages yet
|
||||
@ -611,7 +611,7 @@ if (! dol_is_dir($dirins))
|
||||
}
|
||||
$dirins_ok=(dol_is_dir($dirins));
|
||||
|
||||
llxHeader('', $langs->trans("ModuleBuilder"), "", '', 0, 0,
|
||||
llxHeader('', $langs->trans("ModuleBuilder"), '', '', 0, 0,
|
||||
array(
|
||||
'/includes/ace/ace.js',
|
||||
'/includes/ace/ext-statusbar.js',
|
||||
@ -998,7 +998,7 @@ elseif (! empty($module))
|
||||
dol_fiche_head($head2, $tab, '', -1, '');
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', '');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@ -1052,7 +1052,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -1314,7 +1314,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -1365,7 +1365,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -1410,7 +1410,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -1454,7 +1454,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file);
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
|
||||
@ -551,6 +551,9 @@ textarea.centpercent {
|
||||
.cursormove {
|
||||
cursor: move;
|
||||
}
|
||||
.cursornotallowed {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
min-width: 10px;
|
||||
@ -3347,6 +3350,9 @@ a.websitebuttonsitepreview img {
|
||||
width: 26px;
|
||||
display: inline-block;
|
||||
}
|
||||
a.websitebuttonsitepreviewdisabled img {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
|
||||
/* ============================================================================== */
|
||||
@ -3664,7 +3670,7 @@ a.cke_dialog_ui_button_ok span {
|
||||
border: 1px solid #ddd;
|
||||
margin: 0;
|
||||
}
|
||||
#statusBar {
|
||||
.aceeditorstatusbar {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
left: 0;
|
||||
|
||||
@ -551,6 +551,9 @@ textarea.centpercent {
|
||||
.cursormove {
|
||||
cursor: move;
|
||||
}
|
||||
.cursornotallowed {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
min-width: 10px;
|
||||
@ -3747,7 +3750,7 @@ a.cke_dialog_ui_button_ok span {
|
||||
border: 1px solid #ddd;
|
||||
margin: 0;
|
||||
}
|
||||
#statusBar {
|
||||
.aceeditorstatusbar {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
left: 0;
|
||||
|
||||
@ -85,13 +85,13 @@ class Website extends CommonObject
|
||||
* @var string
|
||||
*/
|
||||
public $virtualhost;
|
||||
|
||||
|
||||
|
||||
|
||||
public $records;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -117,6 +117,7 @@ class Website extends CommonObject
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$error = 0;
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->entity)) {
|
||||
@ -131,7 +132,8 @@ class Website extends CommonObject
|
||||
if (isset($this->status)) {
|
||||
$this->status = trim($this->status);
|
||||
}
|
||||
if (empty($this->date_creation)) $this->date_creation = dol_now();
|
||||
if (empty($this->date_creation)) $this->date_creation = $now;
|
||||
if (empty($this->date_modification)) $this->date_modification = $now;
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
@ -146,6 +148,7 @@ class Website extends CommonObject
|
||||
$sql.= 'virtualhost,';
|
||||
$sql.= 'fk_user_create';
|
||||
$sql.= 'date_creation';
|
||||
$sql.= 'tmps';
|
||||
$sql .= ') VALUES (';
|
||||
$sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).',';
|
||||
$sql .= ' '.(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").',';
|
||||
@ -155,6 +158,7 @@ class Website extends CommonObject
|
||||
$sql .= ' '.(! isset($this->virtualhost)?'NULL':$this->virtualhost).',';
|
||||
$sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).',';
|
||||
$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 .= ')';
|
||||
|
||||
$this->db->begin();
|
||||
@ -230,7 +234,7 @@ class Website extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
|
||||
$this->entity = $obj->entity;
|
||||
$this->ref = $obj->ref;
|
||||
$this->description = $obj->description;
|
||||
@ -297,7 +301,7 @@ class Website extends CommonObject
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield,$sortorder);
|
||||
}
|
||||
@ -314,7 +318,7 @@ class Website extends CommonObject
|
||||
$line = new self($this->db);
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
|
||||
|
||||
$line->entity = $obj->entity;
|
||||
$line->ref = $obj->ref;
|
||||
$line->description = $obj->description;
|
||||
@ -354,7 +358,7 @@ class Website extends CommonObject
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
// Clean parameters
|
||||
|
||||
|
||||
if (isset($this->entity)) {
|
||||
$this->entity = trim($this->entity);
|
||||
}
|
||||
@ -552,7 +556,7 @@ class Website extends CommonObject
|
||||
$result.= $link . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne le libelle du status d'un user (actif, inactif)
|
||||
*
|
||||
@ -607,8 +611,8 @@ class Website extends CommonObject
|
||||
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
@ -618,9 +622,9 @@ class Website extends CommonObject
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
$this->id = 0;
|
||||
|
||||
|
||||
$this->entity = 1;
|
||||
$this->ref = 'myspecimenwebsite';
|
||||
$this->description = 'A specimen website';
|
||||
@ -632,7 +636,7 @@ class Website extends CommonObject
|
||||
$this->date_creation = dol_now();
|
||||
$this->tms = dol_now();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -109,10 +109,10 @@ class WebsitePage extends CommonObject
|
||||
if (isset($this->status)) {
|
||||
$this->status = trim($this->status);
|
||||
}
|
||||
if (isset($this->date_creation)) {
|
||||
if (empty($this->date_creation)) {
|
||||
$this->date_creation = $now;
|
||||
}
|
||||
if (isset($this->date_modification)) {
|
||||
if (empty($this->date_modification)) {
|
||||
$this->date_modification = $now;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ class WebsitePage extends CommonObject
|
||||
$sql .= ' content = '.(isset($this->content)?"'".$this->db->escape($this->content)."'":"null").',';
|
||||
$sql .= ' status = '.(isset($this->status)?$this->status:"null").',';
|
||||
$sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').',';
|
||||
$sql .= ' tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'");
|
||||
//$sql .= ' tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'");
|
||||
$sql .= ' WHERE rowid=' . $this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -70,6 +70,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
|
||||
|
||||
@ -146,8 +147,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') && ! in_array($action, array('updatecss'))) $action='preview';
|
||||
|
||||
// Add page
|
||||
if ($action == 'add')
|
||||
@ -241,56 +241,63 @@ if ($action == 'delete')
|
||||
// Update css
|
||||
if ($action == 'updatecss')
|
||||
{
|
||||
$res = $object->fetch(0, $website);
|
||||
if (GETPOST('refreshsite') || GETPOST('refreshpage')) // If we tried to reload another site/page, we stay on editcss mode.
|
||||
{
|
||||
$action='editcss';
|
||||
}
|
||||
else
|
||||
{
|
||||
$res = $object->fetch(0, $website);
|
||||
|
||||
// Html header file
|
||||
$htmlheadercontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||
$htmlheadercontent.= '<!-- File generated to save common html header - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||
$htmlheadercontent.= '<!-- END -->'."\n";
|
||||
$htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER');
|
||||
// Html header file
|
||||
$htmlheadercontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||
$htmlheadercontent.= '<!-- File generated to save common html header - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||
$htmlheadercontent.= '<!-- END -->'."\n";
|
||||
$htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER');
|
||||
|
||||
dol_syslog("Save file css into ".$filehtmlheader);
|
||||
dol_syslog("Save file css into ".$filehtmlheader);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
}
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
}
|
||||
|
||||
// Css file
|
||||
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||
$csscontent.= '<!-- File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||
$csscontent.= '<?php '."\n";
|
||||
$csscontent.= "header('Content-type: text/css');\n";
|
||||
$csscontent.= "?>"."\n";
|
||||
$csscontent.= '<!-- END -->'."\n";
|
||||
$csscontent.= GETPOST('WEBSITE_CSS_INLINE');
|
||||
// Css file
|
||||
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||
$csscontent.= '<!-- File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||
$csscontent.= '<?php '."\n";
|
||||
$csscontent.= "header('Content-type: text/css');\n";
|
||||
$csscontent.= "?>"."\n";
|
||||
$csscontent.= '<!-- END -->'."\n";
|
||||
$csscontent.= GETPOST('WEBSITE_CSS_INLINE');
|
||||
|
||||
dol_syslog("Save file css into ".$filecss);
|
||||
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));
|
||||
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 (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
}
|
||||
|
||||
$action='preview';
|
||||
$action='preview';
|
||||
}
|
||||
}
|
||||
|
||||
// Update page
|
||||
@ -458,7 +465,7 @@ if ($action == 'updatemeta')
|
||||
}
|
||||
|
||||
// Update page
|
||||
if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))
|
||||
if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))))
|
||||
{
|
||||
$object->fetch(0, $website);
|
||||
|
||||
@ -638,7 +645,13 @@ $form = new Form($db);
|
||||
|
||||
$help_url='';
|
||||
|
||||
llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
|
||||
llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, 0,
|
||||
array(
|
||||
'/includes/ace/ace.js',
|
||||
'/includes/ace/ext-statusbar.js',
|
||||
'/includes/ace/ext-language_tools.js',
|
||||
//'/includes/ace/ext-chromevox.js'
|
||||
), array());
|
||||
|
||||
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -737,7 +750,7 @@ if (count($object->records) > 0)
|
||||
|
||||
if ($action == 'preview')
|
||||
{
|
||||
print '<div class="websiteinputurl">';
|
||||
print '<div class="websiteinputurl" id="websiteinputurl">';
|
||||
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">';
|
||||
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
|
||||
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
|
||||
@ -746,12 +759,9 @@ if (count($object->records) > 0)
|
||||
|
||||
$urlext=$virtualurl;
|
||||
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
|
||||
//if (! empty($object->virtualhost))
|
||||
//{
|
||||
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
|
||||
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'.($urlext?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
|
||||
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'), 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');
|
||||
@ -760,9 +770,9 @@ if (count($object->records) > 0)
|
||||
|
||||
if (in_array($action, array('editcss','editmenu','create')))
|
||||
{
|
||||
if (preg_match('/^create/',$action)) print '<input type="submit" id="savefile" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^edit/',$action)) print '<input type="submit" id="savefile" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
|
||||
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>';
|
||||
@ -857,26 +867,18 @@ if (count($object->records) > 0)
|
||||
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
|
||||
$pagealias = $websitepage->pageurl;
|
||||
|
||||
print '<div class="websiteinputurl">';
|
||||
print '<div class="websiteinputurl" id="websiteinputpage">';
|
||||
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("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta"));
|
||||
print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias');
|
||||
print '</div>';
|
||||
|
||||
if (! empty($object->virtualhost))
|
||||
{
|
||||
$urlext=$virtualurl.'/'.$pagealias.'.php';
|
||||
print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">';
|
||||
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="websitebuttonsitepreview" id="previewpageextnoclick" href="#">';
|
||||
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
|
||||
print '</a>';
|
||||
}
|
||||
$urlext=$virtualurl.'/'.$pagealias.'.php';
|
||||
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
|
||||
print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
|
||||
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'), 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');
|
||||
@ -887,9 +889,9 @@ if (count($object->records) > 0)
|
||||
}
|
||||
if (! in_array($action, array('editcss','editmenu','create')))
|
||||
{
|
||||
if (preg_match('/^create/',$action)) print '<input type="submit" id="savefile" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if (preg_match('/^edit/',$action)) print '<input type="submit" id="savefile" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
|
||||
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
|
||||
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>';
|
||||
@ -901,6 +903,11 @@ if (count($object->records) > 0)
|
||||
{
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery("#websiteinputurl").keyup(function() {
|
||||
console.log("Website external url modified "+jQuery("#previewsiteurl").val());
|
||||
if (jQuery("#previewsiteurl").val() != "") jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
|
||||
else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
|
||||
});
|
||||
jQuery("#previewsiteext,#previewpageext").click(function() {
|
||||
newurl=jQuery("#previewsiteurl").val();
|
||||
newpage=jQuery("#previewsiteurl").val() + "/" + jQuery("#previewpageurl").val() + ".php";
|
||||
@ -953,14 +960,17 @@ if ($action == 'editcss')
|
||||
|
||||
print '<br>';
|
||||
|
||||
$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);
|
||||
|
||||
if (! trim($csscontent)) $csscontent='/* CSS content (all website) */';
|
||||
|
||||
$htmlheader = @file_get_contents($filehtmlheader);
|
||||
// Clean the php css file to remove php code and get only html part
|
||||
$htmlheader = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $htmlheader);
|
||||
|
||||
|
||||
$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);
|
||||
if (! trim($htmlheader)) $htmlheader='<html><!-- HTML header content (all website) --></html>';
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
@ -976,17 +986,25 @@ if ($action == 'editcss')
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_CSS_INLINE');
|
||||
print '</td><td>';
|
||||
print '<textarea class="flat centpercent" rows="20" name="WEBSITE_CSS_INLINE">';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, 'CSS', 'css');
|
||||
|
||||
/*print '<textarea class="flat centpercent" rows="20" name="WEBSITE_CSS_INLINE">';
|
||||
print $csscontent;
|
||||
print '</textarea>';
|
||||
print '</textarea>';*/
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="tdtop">';
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_HTML_HEADER');
|
||||
print '</td><td>';
|
||||
print '<textarea class="flat centpercent" rows="20" name="WEBSITE_HTML_HEADER">';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheader, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, 'HTML Header', 'html');
|
||||
|
||||
/*print '<textarea class="flat centpercent" rows="20" name="WEBSITE_HTML_HEADER">';
|
||||
print $htmlheader;
|
||||
print '</textarea>';
|
||||
print '</textarea>';*/
|
||||
print '</td></tr>';
|
||||
|
||||
/*print '<tr><td>';
|
||||
@ -1032,13 +1050,13 @@ if ($action == 'editmeta' || $action == 'create')
|
||||
if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION');
|
||||
if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS');
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">';
|
||||
print $langs->trans('WEBSITE_PAGENAME');
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat" size="96" name="WEBSITE_PAGENAME" value="'.$pageurl.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>';
|
||||
print '<tr><td class="fieldrequired">';
|
||||
print $langs->trans('WEBSITE_TITLE');
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat" size="96" name="WEBSITE_TITLE" value="'.$pagetitle.'">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user