From 1e7aa4d9b4f408d7430ef6147792657aad24496b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Jul 2017 16:38:00 +0200 Subject: [PATCH 1/2] Work on module website --- htdocs/admin/websites.php | 19 ++- htdocs/core/class/doleditor.class.php | 31 ++-- htdocs/langs/en_US/website.lang | 1 + htdocs/modulebuilder/index.php | 14 +- htdocs/theme/eldy/style.css.php | 8 +- htdocs/theme/md/style.css.php | 5 +- htdocs/websites/class/website.class.php | 34 +++-- htdocs/websites/class/websitepage.class.php | 6 +- htdocs/websites/index.php | 149 +++++++++++--------- 9 files changed, 156 insertions(+), 111 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 61fa7bc17f3..ee75a811347 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -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/websiteref')); // 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 diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 3760dc04081..db768b4c630 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -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.= ''."\n"; + $out.= "\n".''."\n"; if ($titlecontent) { - $out.= '
'.$titlecontent; - $out.= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; + $out.= '
'.$titlecontent; + $out.= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; $out.= '
'; $out.= ''."\n"; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index cc2f31143ce..18d9193b3f9 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -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 %s
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.

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:
%s
URL served by external server:
%s PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
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 \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1fc949c6f02..d789dc77b55 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -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 ''; $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 '
'; print '
'; print ''; @@ -1314,7 +1314,7 @@ elseif (! empty($module)) print ''; $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 '
'; print '
'; print ''; @@ -1365,7 +1365,7 @@ elseif (! empty($module)) print ''; $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 '
'; print '
'; print ''; @@ -1410,7 +1410,7 @@ elseif (! empty($module)) print ''; $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 '
'; print '
'; print ''; @@ -1454,7 +1454,7 @@ elseif (! empty($module)) print ''; $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 '
'; print '
'; print ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 46650804063..a42ed7bf6a0 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -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; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 55a83326e75..4a396fadc7b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -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; diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index a77079c94a6..167e186e124 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -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(); - + } } diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 4f9dc58c615..77e5d5862ec 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -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(); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 2c9c364edac..3ef79ec01b9 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -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 = ''."\n"; - $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + // Html header file + $htmlheadercontent = ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\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 = ''."\n"; - $csscontent.= ''."\n"; - $csscontent.= '"."\n"; - $csscontent.= ''."\n"; - $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); + // Css file + $csscontent = ''."\n"; + $csscontent.= ''."\n"; + $csscontent.= '"."\n"; + $csscontent.= ''."\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".'
'; print ''; @@ -746,12 +759,9 @@ if (count($object->records) > 0) $urlext=$virtualurl; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; - //if (! empty($object->virtualhost)) - //{ - print '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 ''; - //} + print '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 ''; print '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 ''; + if (preg_match('/^edit/',$action)) print ''; if ($action != 'preview') print ''; - if (preg_match('/^create/',$action)) print ''; - if (preg_match('/^edit/',$action)) print ''; } print '
'; @@ -887,9 +897,9 @@ if (count($object->records) > 0) } if (! in_array($action, array('editcss','editmenu','create'))) { + if (preg_match('/^create/',$action)) print ''; + if (preg_match('/^edit/',$action)) print ''; if ($action != 'preview') print ''; - if (preg_match('/^create/',$action)) print ''; - if (preg_match('/^edit/',$action)) print ''; } print '
'; @@ -953,14 +963,17 @@ if ($action == 'editcss') print '
'; + $csscontent = @file_get_contents($filecss); + // Clean the php css file to remove php code and get only css part + $csscontent = preg_replace('//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('//s', '', $htmlheader); - - $csscontent = @file_get_contents($filecss); - // Clean the php css file to remove php code and get only css part - $csscontent = preg_replace('//s', '', $csscontent); + if (! trim($htmlheader)) $htmlheader=''; dol_fiche_head(); @@ -976,17 +989,25 @@ if ($action == 'editcss') print ''; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; - print ''; + print '';*/ print ''; - print ''; + print ''; print $langs->trans('WEBSITE_HTML_HEADER'); print ''; - print ''; + print '';*/ print ''; /*print ''; @@ -1032,13 +1053,13 @@ if ($action == 'editmeta' || $action == 'create') if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION'); if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS'); - print ''; + print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; print ''; print ''; - print ''; + print ''; print $langs->trans('WEBSITE_TITLE'); print ''; print ''; From 2621c55bf440cd72da97ad6e204a1796202633fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2017 11:51:30 +0200 Subject: [PATCH 2/2] Link of preview is enabled only if setup is correct. --- htdocs/websites/index.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 3ef79ec01b9..874679892d5 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -750,7 +750,7 @@ if (count($object->records) > 0) if ($action == 'preview') { - print '
'; + print '
'; print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); @@ -867,26 +867,18 @@ if (count($object->records) > 0) $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $pagealias = $websitepage->pageurl; - print '
'; + print '
'; print ''; //print ''; $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '
'; - if (! empty($object->virtualhost)) - { - $urlext=$virtualurl.'/'.$pagealias.'.php'; - print '
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 ''; - } - else - { - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - } + $urlext=$virtualurl.'/'.$pagealias.'.php'; + $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + print ''; print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); @@ -911,6 +903,11 @@ if (count($object->records) > 0) { print '