2016-01-24 21:35:41 +01:00
< ? php
2020-02-20 01:08:53 +01:00
/* Copyright ( C ) 2016 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2016-01-24 21:35:41 +01:00
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2016-01-24 21:35:41 +01:00
*/
/**
2016-05-01 19:49:03 +02:00
* \file htdocs / website / index . php
2016-02-02 16:24:12 +01:00
* \ingroup website
2016-05-01 19:49:03 +02:00
* \brief Page to website view / edit
2016-01-24 21:35:41 +01:00
*/
2019-01-27 11:55:16 +01:00
define ( 'NOSCANPOSTFORINJECTION' , 1 );
define ( 'NOSTYLECHECK' , 1 );
2019-08-13 05:22:49 +02:00
define ( 'USEDOLIBARREDITOR' , 1 );
2020-02-21 17:53:37 +01:00
define ( 'FORCE_CKEDITOR' , 1 ); // We need CKEditor, even if module is off.
2016-05-01 19:49:03 +02:00
2019-12-07 15:46:14 +01:00
//header('X-XSS-Protection:0'); // Disable XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated.
2019-01-04 19:10:25 +01:00
2016-01-24 21:35:41 +01:00
require '../main.inc.php' ;
2016-02-02 16:24:12 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2016-05-01 16:34:50 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2017-08-21 03:13:44 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/website.lib.php' ;
2019-08-12 22:19:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/website2.lib.php' ;
2017-07-19 16:38:00 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2017-07-22 20:01:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php' ;
2017-07-23 16:20:53 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formwebsite.class.php' ;
2018-02-19 19:47:42 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2017-10-20 21:39:19 +02:00
require_once DOL_DOCUMENT_ROOT . '/website/class/website.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/website/class/websitepage.class.php' ;
2020-05-26 00:19:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2016-02-02 16:24:12 +01:00
2020-02-21 17:53:37 +01:00
$langs -> loadLangs ( array ( " admin " , " other " , " website " , " errors " ));
2016-02-02 16:24:12 +01:00
2020-02-21 17:53:37 +01:00
if ( ! $user -> rights -> website -> read ) accessforbidden ();
2016-02-02 16:24:12 +01:00
2020-02-21 17:53:37 +01:00
$conf -> dol_hide_leftmenu = 1 ; // Force hide of left menu.
2016-04-19 11:02:55 +02:00
2020-02-21 17:53:37 +01:00
$error = 0 ;
$websiteid = GETPOST ( 'websiteid' , 'int' );
$websitekey = GETPOST ( 'website' , 'alpha' );
$page = GETPOST ( 'page' , 'alpha' );
$pageid = GETPOST ( 'pageid' , 'int' );
2020-03-13 10:05:54 +01:00
$pageref = GETPOST ( 'pageref' , 'alphanohtml' );
2020-04-11 18:18:53 +02:00
2020-02-21 17:53:37 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-11 18:18:53 +02:00
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
2020-02-21 17:53:37 +01:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
2020-04-11 18:18:53 +02:00
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
2020-02-21 17:53:37 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'bomlist' ; // To manage different context of search
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2017-11-18 15:41:30 +01:00
2020-02-21 17:53:37 +01:00
$type_container = GETPOST ( 'WEBSITE_TYPE_CONTAINER' , 'alpha' );
2017-12-02 13:24:21 +01:00
2017-11-18 15:41:30 +01:00
$section_dir = GETPOST ( 'section_dir' , 'alpha' );
$file_manager = GETPOST ( 'file_manager' , 'alpha' );
2019-05-28 16:10:11 +02:00
$replacesite = GETPOST ( 'replacesite' , 'alpha' );
2016-02-02 16:24:12 +01:00
2020-02-21 17:53:37 +01:00
if ( GETPOST ( 'deletesite' , 'alpha' )) { $action = 'deletesite' ; }
if ( GETPOST ( 'delete' , 'alpha' )) { $action = 'delete' ; }
if ( GETPOST ( 'preview' , 'alpha' )) $action = 'preview' ;
if ( GETPOST ( 'createsite' , 'alpha' )) { $action = 'createsite' ; }
if ( GETPOST ( 'createcontainer' , 'alpha' )) { $action = 'createcontainer' ; }
if ( GETPOST ( 'editcss' , 'alpha' )) { $action = 'editcss' ; }
if ( GETPOST ( 'editmenu' , 'alpha' )) { $action = 'editmenu' ; }
if ( GETPOST ( 'setashome' , 'alpha' )) { $action = 'setashome' ; }
if ( GETPOST ( 'editmeta' , 'alpha' )) { $action = 'editmeta' ; }
if ( GETPOST ( 'editsource' , 'alpha' )) { $action = 'editsource' ; }
if ( GETPOST ( 'editcontent' , 'alpha' )) { $action = 'editcontent' ; }
if ( GETPOST ( 'exportsite' , 'alpha' )) { $action = 'exportsite' ; }
if ( GETPOST ( 'importsite' , 'alpha' )) { $action = 'importsite' ; }
if ( GETPOST ( 'createfromclone' , 'alpha' )) { $action = 'createfromclone' ; }
if ( GETPOST ( 'createpagefromclone' , 'alpha' )) { $action = 'createpagefromclone' ; }
if ( empty ( $action ) && $file_manager ) $action = 'file_manager' ;
if ( empty ( $action ) && $replacesite ) $action = 'replacesite' ;
2016-04-19 11:02:55 +02:00
2019-11-09 12:03:11 +01:00
if ( GETPOST ( 'refreshsite' ) || GETPOST ( 'refreshsite_x' ) || GETPOST ( 'refreshsite.x' )) $pageid = 0 ;
2017-11-10 13:45:38 +01:00
// Load variable for pagination
2020-02-21 17:53:37 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2019-01-27 11:55:16 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2017-11-10 13:45:38 +01:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
//if (! $sortfield) $sortfield='name';
//if (! $sortorder) $sortorder='ASC';
2019-11-12 00:15:34 +01:00
if ( empty ( $action )) $action = 'preview' ;
2016-01-24 21:35:41 +01:00
2019-11-12 00:15:34 +01:00
$object = new Website ( $db );
$objectpage = new WebsitePage ( $db );
2016-02-02 16:24:12 +01:00
2020-05-27 14:50:10 +02:00
$object -> fetchAll ( 'ASC' , 'position' ); // Init $object->records with list of websites
2016-04-29 20:35:38 +02:00
// If website not defined, we take first found
2019-11-12 00:15:34 +01:00
if ( ! ( $websiteid > 0 ) && empty ( $websitekey ))
2016-04-29 20:35:38 +02:00
{
2019-11-12 00:15:34 +01:00
foreach ( $object -> records as $key => $valwebsite )
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$websitekey = $valwebsite -> ref ;
2017-10-07 13:09:31 +02:00
break ;
}
2016-04-29 20:35:38 +02:00
}
2019-10-31 21:09:33 +01:00
if ( $websiteid > 0 || $websitekey )
2016-04-23 21:34:10 +02:00
{
2019-10-31 21:09:33 +01:00
$res = $object -> fetch ( $websiteid , $websitekey );
$websitekey = $object -> ref ;
2016-04-23 21:34:10 +02:00
}
2019-10-31 21:09:33 +01:00
2018-07-22 17:18:35 +02:00
$website = $object ;
2016-05-01 19:49:03 +02:00
2020-03-23 14:12:48 +01:00
// Check pageid received as parameter
2018-09-24 17:12:51 +02:00
if ( $pageid < 0 ) $pageid = 0 ;
if (( $pageid > 0 || $pageref ) && $action != 'addcontainer' )
{
$res = $objectpage -> fetch ( $pageid , ( $object -> id > 0 ? $object -> id : null ), $pageref );
2019-02-05 15:15:41 +01:00
if ( $res == 0 )
{
$res = $objectpage -> fetch ( $pageid , ( $object -> id > 0 ? $object -> id : null ), null , $pageref );
}
2018-09-24 17:12:51 +02:00
// Check if pageid is inside the new website, if not we reset param pageid
if ( $res >= 0 && $object -> id > 0 )
{
2018-10-01 13:09:12 +02:00
if ( $objectpage -> fk_website != $object -> id ) // We have a bad page that does not belong to web site
2018-09-24 17:12:51 +02:00
{
2018-10-01 13:09:12 +02:00
if ( $object -> fk_default_home > 0 )
2018-09-24 17:12:51 +02:00
{
2019-11-12 00:15:34 +01:00
$res = $objectpage -> fetch ( $object -> fk_default_home , $object -> id , '' ); // We search first page of web site
2018-10-01 13:09:12 +02:00
if ( $res > 0 ) $pageid = $object -> fk_default_home ;
2018-09-24 17:12:51 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$res = $objectpage -> fetch ( 0 , $object -> id , '' ); // We search first page of web site
2018-10-01 13:09:12 +02:00
if ( $res == 0 ) // Page was not found, we reset it
{
2019-11-12 00:15:34 +01:00
$objectpage = new WebsitePage ( $db );
2018-10-01 13:09:12 +02:00
}
2020-05-21 09:07:10 +02:00
else // We found a page, we set pageid to it.
2018-10-01 13:09:12 +02:00
{
$pageid = $objectpage -> id ;
}
2018-09-24 17:12:51 +02:00
}
}
2020-05-21 09:07:10 +02:00
else // We have a valid page. We force pageid for the case we got the page with a fetch on ref.
2018-09-24 17:12:51 +02:00
{
$pageid = $objectpage -> id ;
}
}
}
// Define pageid if pageid and pageref not received as parameter or was wrong
2018-09-24 15:14:32 +02:00
if ( empty ( $pageid ) && empty ( $pageref ) && $object -> id > 0 && $action != 'createcontainer' )
{
$pageid = $object -> fk_default_home ;
if ( empty ( $pageid ))
{
2019-11-12 00:15:34 +01:00
$array = $objectpage -> fetchAll ( $object -> id , 'ASC,ASC' , 'type_container,pageurl' );
if ( ! is_array ( $array ) && $array < 0 ) dol_print_error ( '' , $objectpage -> error , $objectpage -> errors );
$atleastonepage = ( is_array ( $array ) && count ( $array ) > 0 );
2018-09-24 15:14:32 +02:00
2019-11-12 00:15:34 +01:00
$firstpageid = 0 ; $homepageid = 0 ;
foreach ( $array as $key => $valpage )
2018-09-24 15:14:32 +02:00
{
2019-11-12 00:15:34 +01:00
if ( empty ( $firstpageid )) $firstpageid = $valpage -> id ;
if ( $object -> fk_default_home && $key == $object -> fk_default_home ) $homepageid = $valpage -> id ;
2018-09-24 15:14:32 +02:00
}
2019-11-12 00:15:34 +01:00
$pageid = ( $homepageid ? $homepageid : $firstpageid ); // We choose home page and if not defined yet, we take first page
2018-09-24 15:14:32 +02:00
}
}
2016-04-23 21:34:10 +02:00
2016-05-01 16:34:50 +02:00
global $dolibarr_main_data_root ;
2019-11-12 00:15:34 +01:00
$pathofwebsite = $dolibarr_main_data_root . '/website/' . $websitekey ;
$filehtmlheader = $pathofwebsite . '/htmlheader.html' ;
$filecss = $pathofwebsite . '/styles.css.php' ;
$filejs = $pathofwebsite . '/javascript.js.php' ;
$filerobot = $pathofwebsite . '/robots.txt' ;
$filehtaccess = $pathofwebsite . '/.htaccess' ;
$filetpl = $pathofwebsite . '/page' . $pageid . '.tpl.php' ;
$fileindex = $pathofwebsite . '/index.php' ;
$filewrapper = $pathofwebsite . '/wrapper.php' ;
$filemanifestjson = $pathofwebsite . '/manifest.json.php' ;
$filereadme = $pathofwebsite . '/README.md' ;
2020-05-23 13:10:33 +02:00
$filemaster = $pathofwebsite . '/master.inc.php' ;
2016-05-01 16:34:50 +02:00
2016-05-07 16:38:32 +02:00
// Define $urlwithroot
2019-11-12 00:15:34 +01:00
$urlwithouturlroot = preg_replace ( '/' . preg_quote ( DOL_URL_ROOT , '/' ) . '$/i' , '' , trim ( $dolibarr_main_url_root ));
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT ; // This is to use external domain name found into config file
2016-05-07 16:38:32 +02:00
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
2016-05-01 16:34:50 +02:00
2017-11-18 15:41:30 +01:00
$permtouploadfile = $user -> rights -> website -> write ;
$diroutput = $conf -> medias -> multidir_output [ $conf -> entity ];
2019-11-12 00:15:34 +01:00
$relativepath = $section_dir ;
2017-11-18 15:41:30 +01:00
$upload_dir = $diroutput . '/' . $relativepath ;
2018-01-08 12:31:11 +01:00
$htmlheadercontentdefault = '' ;
2019-11-12 00:15:34 +01:00
$htmlheadercontentdefault .= '<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />' . " \n " ;
$htmlheadercontentdefault .= '<link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />' . " \n " ;
$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '<!--' . " \n " ;
$htmlheadercontentdefault .= '<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>' . " \n " ;
$htmlheadercontentdefault .= '<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>' . " \n " ;
$htmlheadercontentdefault .= '-->' . " \n " ;
2018-01-02 17:27:05 +01:00
2019-08-12 17:34:18 +02:00
$manifestjsoncontentdefault = '' ;
2019-11-12 00:15:34 +01:00
$manifestjsoncontentdefault .= ' {
2019-08-12 17:34:18 +02:00
" name " : " MyWebsite " ,
" short_name " : " MyWebsite " ,
" start_url " : " / " ,
" lang " : " en-US " ,
" display " : " standalone " ,
" background_color " : " #fff " ,
" description " : " A simple Web app. " ,
" icons " : [{
" src " : " images/'. $website->ref .'/homescreen48.png " ,
" sizes " : " 48x48 " ,
" type " : " image/png "
}, {
" src " : " image/'. $website->ref .'/homescreen72.png " ,
" sizes " : " 72x72 " ,
" type " : " image/png "
}, {
" src " : " image/'. $website->ref .'/homescreen96.png " ,
" sizes " : " 96x96 " ,
" type " : " image/png "
}, {
" src " : " image/'. $website->ref .'/homescreen144.png " ,
" sizes " : " 144x144 " ,
" type " : " image/png "
}, {
" src " : " image/'. $website->ref .'/homescreen168.png " ,
" sizes " : " 168x168 " ,
" type " : " image/png "
}, {
" src " : " image/'. $website->ref .'/homescreen192.png " ,
" sizes " : " 192x192 " ,
" type " : " image/png "
}],
" related_applications " : [{
" platform " : " play " ,
" url " : " https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro "
}]
} ' ;
2020-04-11 18:18:53 +02:00
$listofpages = array ();
$algo = '' ;
if ( GETPOST ( 'optionmeta' )) $algo .= 'meta' ;
if ( GETPOST ( 'optioncontent' )) $algo .= 'content' ;
if ( GETPOST ( 'optionsitefiles' )) $algo .= 'sitefiles' ;
if ( empty ( $sortfield )) {
2020-05-03 13:00:39 +02:00
if ( $action == 'file_manager' ) {
$sortfield = 'name' ; $sortorder = 'ASC' ;
} else {
$sortfield = 'pageurl' ; $sortorder = 'ASC' ;
}
2020-04-11 18:18:53 +02:00
}
$searchkey = GETPOST ( 'searchstring' , 'none' );
if ( $action == 'replacesiteconfirm' ) {
2020-05-26 12:25:41 +02:00
$containertype = GETPOST ( 'optioncontainertype' , 'aZ09' ) != '-1' ? GETPOST ( 'optioncontainertype' , 'aZ09' ) : '' ;
$langcode = GETPOST ( 'optionlanguage' , 'aZ09' );
$otherfilters = array ();
if ( GETPOST ( 'optioncategory' , 'int' ) > 0 ) {
$otherfilters [ 'category' ] = GETPOST ( 'optioncategory' , 'int' );
}
$listofpages = getPagesFromSearchCriterias ( $containertype , $algo , $searchkey , 1000 , $sortfield , $sortorder , $langcode , $otherfilters );
2020-04-11 18:18:53 +02:00
}
2020-05-26 22:29:46 +02:00
$usercanedit = $user -> rights -> website -> write ;
2019-08-12 17:34:18 +02:00
2017-11-18 15:41:30 +01:00
2016-02-02 16:24:12 +01:00
/*
* Actions
*/
2019-04-05 11:34:06 +02:00
// Protections
2020-02-21 17:53:37 +01:00
if ( GETPOST ( 'refreshsite' ) || GETPOST ( 'refreshsite_x' ) || GETPOST ( 'refreshsite.x' ) || GETPOST ( 'refreshpage' ) || GETPOST ( 'refreshpage_x' ) || GETPOST ( 'refreshpage.x' ))
2019-04-05 11:34:06 +02:00
{
2020-02-21 17:53:37 +01:00
$action = 'preview' ; // To avoid to make an action on another page or another site when we click on button to select another site or page.
2019-04-05 11:34:06 +02:00
}
2019-08-29 13:41:42 +02:00
if ( GETPOST ( 'refreshsite' , 'alpha' ) || GETPOST ( 'refreshsite.x' , 'alpha' ) || GETPOST ( 'refreshsite_x' , 'alpha' )) // If we change the site, we reset the pageid and cancel addsite action.
2019-04-05 11:34:06 +02:00
{
if ( $action == 'addsite' ) $action = 'preview' ;
if ( $action == 'updatesource' ) $action = 'preview' ;
2019-11-09 11:30:08 +01:00
$pageid = $object -> fk_default_home ;
if ( empty ( $pageid ))
{
2020-02-21 17:53:37 +01:00
$array = $objectpage -> fetchAll ( $object -> id , 'ASC,ASC' , 'type_container,pageurl' );
if ( ! is_array ( $array ) && $array < 0 ) dol_print_error ( '' , $objectpage -> error , $objectpage -> errors );
$atleastonepage = ( is_array ( $array ) && count ( $array ) > 0 );
2019-11-09 11:30:08 +01:00
2020-02-21 17:53:37 +01:00
$firstpageid = 0 ; $homepageid = 0 ;
foreach ( $array as $key => $valpage )
2019-11-09 11:30:08 +01:00
{
2020-02-21 17:53:37 +01:00
if ( empty ( $firstpageid )) $firstpageid = $valpage -> id ;
if ( $object -> fk_default_home && $key == $object -> fk_default_home ) $homepageid = $valpage -> id ;
2019-11-09 11:30:08 +01:00
}
2020-02-21 17:53:37 +01:00
$pageid = ( $homepageid ? $homepageid : $firstpageid ); // We choose home page and if not defined yet, we take first page
2019-11-09 11:30:08 +01:00
}
2019-04-05 11:34:06 +02:00
}
2020-02-21 17:53:37 +01:00
if ( GETPOST ( 'refreshpage' , 'alpha' ) && ! in_array ( $action , array ( 'updatecss' ))) $action = 'preview' ;
2019-04-05 11:34:06 +02:00
2019-09-02 18:43:22 +02:00
// Cancel
if ( $cancel )
{
$action = 'preview' ;
if ( $backtopage )
{
header ( " Location: " . $backtopage );
exit ;
}
}
2019-04-05 11:34:06 +02:00
2019-09-02 18:43:22 +02:00
$savbacktopage = $backtopage ;
2019-11-12 00:15:34 +01:00
$backtopage = $_SERVER [ " PHP_SELF " ] . '?file_manager=1&website=' . $websitekey . '&pageid=' . $pageid . ( GETPOST ( 'section_dir' , 'alpha' ) ? '§ion_dir=' . urlencode ( GETPOST ( 'section_dir' , 'alpha' )) : '' ); // used after a confirm_deletefile into actions_linkedfiles.inc.php
2020-04-23 18:55:10 +02:00
if ( $sortfield ) $backtopage .= '&sortfield=' . $sortfield ;
if ( $sortorder ) $backtopage .= '&sortorder=' . $sortorder ;
2017-11-18 15:41:30 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php' ;
2019-09-02 18:43:22 +02:00
$backtopage = $savbacktopage ;
2017-11-18 15:41:30 +01:00
2019-11-12 00:15:34 +01:00
if ( $action == 'renamefile' ) $action = 'file_manager' ; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager'
2017-11-18 15:41:30 +01:00
2018-07-20 15:01:50 +02:00
if ( $action == 'seteditinline' )
{
dolibarr_set_const ( $db , 'WEBSITE_EDITINLINE' , 1 );
2018-09-24 15:38:13 +02:00
setEventMessages ( $langs -> trans ( " FeatureNotYetAvailable " ), null , 'warnings' );
2019-11-12 00:15:34 +01:00
dolibarr_set_const ( $db , 'WEBSITE_SUBCONTAINERSINLINE' , 0 ); // Force disable of 'Include dynamic content'
2019-01-27 11:55:16 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . GETPOST ( 'website' , 'alphanohtml' ) . '&pageid=' . GETPOST ( 'pageid' , 'int' ));
2018-07-20 15:01:50 +02:00
exit ;
}
if ( $action == 'unseteditinline' )
{
dolibarr_del_const ( $db , 'WEBSITE_EDITINLINE' );
2019-01-27 11:55:16 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . GETPOST ( 'website' , 'alphanohtml' ) . '&pageid=' . GETPOST ( 'pageid' , 'int' ));
2018-09-10 19:36:46 +02:00
exit ;
}
if ( $action == 'setshowsubcontainers' )
{
dolibarr_set_const ( $db , 'WEBSITE_SUBCONTAINERSINLINE' , 1 );
2019-11-12 00:15:34 +01:00
dolibarr_set_const ( $db , 'WEBSITE_EDITINLINE' , 0 ); // Force disable of edit inline
2019-01-27 11:55:16 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . GETPOST ( 'website' , 'alphanohtml' ) . '&pageid=' . GETPOST ( 'pageid' , 'int' ));
2018-09-10 19:36:46 +02:00
exit ;
}
if ( $action == 'unsetshowsubcontainers' )
{
dolibarr_del_const ( $db , 'WEBSITE_SUBCONTAINERSINLINE' );
2019-01-27 11:55:16 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . GETPOST ( 'website' , 'alphanohtml' ) . '&pageid=' . GETPOST ( 'pageid' , 'int' ));
2018-07-20 15:01:50 +02:00
exit ;
}
2020-05-26 12:46:51 +02:00
if ( $massaction == 'replace' && GETPOST ( 'confirmmassaction' , 'alpha' ) && ! $searchkey )
2019-08-13 00:34:42 +02:00
{
$action = 'replacesite' ;
2020-05-26 12:46:51 +02:00
$massaction = '' ;
2019-08-13 00:34:42 +02:00
}
2020-05-26 22:29:46 +02:00
// Set categoery
if ( $massaction == 'setcategory' && GETPOST ( 'confirmmassaction' , 'alpha' ) && $usercanedit )
{
$error = 0 ;
$db -> begin ();
$categoryid = GETPOST ( 'setcategory' , 'none' );
if ( $categoryid > 0 ) {
$nbupdate = 0 ;
$tmpwebsitepage = new WebsitePage ( $db );
$category = new Categorie ( $db );
$category -> fetch ( $categoryid );
foreach ( $toselect as $tmpid ) {
$tmpwebsitepage -> id = $tmpid ;
$result = $category -> add_type ( $tmpwebsitepage , 'website_page' );
if ( $result < 0 && $result != - 3 ) {
$error ++ ;
setEventMessages ( $category -> error , $category -> errors , 'errors' );
break ;
} else {
$nbupdate ++ ;
}
}
}
if ( $error ) {
$db -> rollback ();
} else {
if ( $nbupdate ) {
setEventMessages ( $langs -> trans ( " RecordsModified " , $nbupdate ), null , 'mesgs' );
}
$db -> commit ();
}
// Now we reload list
$listofpages = getPagesFromSearchCriterias ( $containertype , $algo , $searchkey , 1000 , $sortfield , $sortorder , $langcode , $otherfilters );
}
2020-04-11 18:18:53 +02:00
// Replacement of string into pages
2020-04-13 00:06:25 +02:00
if ( $massaction == 'replace' && GETPOST ( 'confirmmassaction' , 'alpha' ))
2020-04-11 18:18:53 +02:00
{
2020-04-13 00:06:25 +02:00
$replacestring = GETPOST ( 'replacestring' , 'none' );
2020-04-12 13:25:19 +02:00
if ( empty ( $user -> rights -> website -> writephp )) {
setEventMessages ( " NotAllowedToAddDynamicContent " , null , 'errors' );
}
2020-04-13 13:24:42 +02:00
elseif ( ! $replacestring ) {
2020-04-11 18:18:53 +02:00
setEventMessages ( " ErrorReplaceStringEmpty " , null , 'errors' );
}
else {
$nbreplacement = 0 ;
2020-04-13 13:24:42 +02:00
foreach ( $toselect as $keyselected ) {
2020-04-11 18:18:53 +02:00
$objectpage = $listofpages [ 'list' ][ $keyselected ];
if ( $objectpage -> pageurl ) {
dol_syslog ( " Replace string into page " . $objectpage -> pageurl );
if ( GETPOST ( 'optioncontent' , 'aZ09' )) {
$objectpage -> content = str_replace ( $searchkey , $replacestring , $objectpage -> content );
}
if ( GETPOST ( 'optionmeta' , 'aZ09' )) {
$objectpage -> title = str_replace ( $searchkey , $replacestring , $objectpage -> title );
$objectpage -> description = str_replace ( $searchkey , $replacestring , $objectpage -> description );
$objectpage -> keywords = str_replace ( $searchkey , $replacestring , $objectpage -> keywords );
}
2020-04-11 18:29:42 +02:00
$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 ' . basename ( $filealias ), null , 'errors' );
}
// Save page of content
$result = dolSavePageContent ( $filetpl , $object , $objectpage );
if ( $result )
2020-04-11 18:18:53 +02:00
{
2020-04-11 18:29:42 +02:00
$nbreplacement ++ ;
//var_dump($objectpage->content);exit;
$objectpage -> update ( $user );
} else {
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filetpl , null , 'errors' );
$action = 'createcontainer' ;
break ;
2020-04-11 18:18:53 +02:00
}
}
}
2020-04-11 18:29:42 +02:00
if ( $nbreplacement > 0 ) {
2020-04-11 18:18:53 +02:00
setEventMessages ( $langs -> trans ( " ReplacementDoneInXPages " , $nbreplacement ), null , 'mesgs' );
}
2020-04-11 18:29:42 +02:00
2020-05-26 12:25:41 +02:00
$containertype = GETPOST ( 'optioncontainertype' , 'aZ09' ) != '-1' ? GETPOST ( 'optioncontainertype' , 'aZ09' ) : '' ;
$langcode = GETPOST ( 'optionlanguage' , 'aZ09' );
$otherfilters = array ();
if ( GETPOST ( 'optioncategory' , 'int' ) > 0 ) {
$otherfilters [ 'category' ] = GETPOST ( 'optioncategory' , 'int' );
}
2020-04-11 18:29:42 +02:00
// Now we reload list
2020-05-26 12:25:41 +02:00
$listofpages = getPagesFromSearchCriterias ( $containertype , $algo , $searchkey , 1000 , $sortfield , $sortorder , $langcode , $otherfilters );
2020-04-11 18:18:53 +02:00
}
}
2019-08-13 00:34:42 +02:00
2017-11-18 15:41:30 +01:00
// Add directory
2017-12-02 13:24:21 +01:00
/*
if ( $action == 'adddir' && $permtouploadfile )
2017-11-18 15:41:30 +01:00
{
$ecmdir -> ref = 'NOTUSEDYET' ;
$ecmdir -> label = GETPOST ( " label " );
$ecmdir -> description = GETPOST ( " desc " );
//$id = $ecmdir->create($user);
if ( $id > 0 )
{
header ( " Location: " . $_SERVER [ " PHP_SELF " ]);
exit ;
}
else
{
setEventMessages ( 'Error ' . $langs -> trans ( $ecmdir -> error ), null , 'errors' );
2017-12-12 01:40:34 +01:00
$action = " createcontainer " ;
2017-11-18 15:41:30 +01:00
}
clearstatcache ();
}
2017-12-02 13:24:21 +01:00
*/
2017-11-18 15:41:30 +01:00
2017-09-01 12:19:55 +02:00
// Add site
if ( $action == 'addsite' )
{
$db -> begin ();
2019-11-12 00:15:34 +01:00
if ( GETPOST ( 'virtualhost' , 'alpha' ) && ! preg_match ( '/^http/' , GETPOST ( 'virtualhost' , 'alpha' )))
2019-01-23 15:06:28 +01:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( 'ErrorURLMustStartWithHttp' , $langs -> transnoentitiesnoconv ( " VirtualHost " )), null , 'errors' );
}
2019-11-12 00:15:34 +01:00
if ( ! $error && ! GETPOST ( 'WEBSITE_REF' , 'alpha' ))
2017-09-01 12:19:55 +02:00
{
$error ++ ;
2018-08-20 19:10:33 +02:00
$langs -> load ( " errors " );
2017-09-01 12:19:55 +02:00
setEventMessages ( $langs -> transnoentities ( " ErrorFieldRequired " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
}
2019-11-12 00:15:34 +01:00
if ( ! $error && ! preg_match ( '/^[a-z0-9_\-\.]+$/i' , GETPOST ( 'WEBSITE_REF' , 'alpha' )))
2017-09-01 12:19:55 +02:00
{
$error ++ ;
2018-02-19 16:46:29 +01:00
$langs -> load ( " errors " );
2017-09-01 12:19:55 +02:00
setEventMessages ( $langs -> transnoentities ( " ErrorFieldCanNotContainSpecialCharacters " , $langs -> transnoentities ( " Ref " )), null , 'errors' );
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-09-01 12:19:55 +02:00
{
2020-04-10 10:59:32 +02:00
$arrayotherlang = explode ( ',' , GETPOST ( 'WEBSITE_OTHERLANG' , 'alphanohtml' ));
foreach ( $arrayotherlang as $key => $val ) {
$arrayotherlang [ $key ] = substr ( trim ( $val ), 0 , 2 ); // Kept short language code only
2020-02-27 22:58:36 +01:00
}
2019-11-12 00:15:34 +01:00
$tmpobject = new Website ( $db );
2019-01-27 11:55:16 +01:00
$tmpobject -> ref = GETPOST ( 'WEBSITE_REF' , 'alpha' );
2020-02-19 18:32:04 +01:00
$tmpobject -> description = GETPOST ( 'WEBSITE_DESCRIPTION' , 'alphanohtml' );
$tmpobject -> lang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
2020-02-27 22:58:36 +01:00
$tmpobject -> otherlang = join ( ',' , $arrayotherlang );
2019-01-27 11:55:16 +01:00
$tmpobject -> virtualhost = GETPOST ( 'virtualhost' , 'alpha' );
2017-09-01 12:19:55 +02:00
$result = $tmpobject -> create ( $user );
if ( $result <= 0 )
{
$error ++ ;
setEventMessages ( $tmpobject -> error , $tmpobject -> errors , 'errors' );
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-09-01 12:19:55 +02:00
{
$db -> commit ();
setEventMessages ( $langs -> trans ( " SiteAdded " , $object -> ref ), null , 'mesgs' );
2019-11-12 00:15:34 +01:00
$action = '' ;
2017-09-01 12:19:55 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $tmpobject -> ref );
exit ;
}
2020-05-21 09:07:10 +02:00
else {
2017-09-01 12:19:55 +02:00
$db -> rollback ();
2019-11-12 00:15:34 +01:00
$action = 'createsite' ;
2017-09-01 12:19:55 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-09-01 12:19:55 +02:00
{
$action = 'preview' ;
$id = $object -> id ;
}
}
2017-12-12 01:40:34 +01:00
// Add page/container
if ( $action == 'addcontainer' )
2016-04-23 21:34:10 +02:00
{
2017-10-13 15:23:24 +02:00
dol_mkdir ( $pathofwebsite );
2017-10-07 13:09:31 +02:00
$db -> begin ();
$objectpage -> fk_website = $object -> id ;
2019-10-31 21:09:33 +01:00
if ( GETPOSTISSET ( 'fetchexternalurl' ))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$urltograb = GETPOST ( 'externalurl' , 'alpha' );
$grabimages = GETPOST ( 'grabimages' , 'alpha' );
$grabimagesinto = GETPOST ( 'grabimagesinto' , 'alpha' );
2018-02-19 14:56:37 +01:00
//var_dump($grabimages);exit;
2017-10-07 13:09:31 +02:00
}
2019-10-31 21:09:33 +01:00
if ( GETPOSTISSET ( 'fetchexternalurl' ))
2017-10-07 13:09:31 +02:00
{
2017-12-10 17:59:19 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php' ;
2019-10-31 21:09:33 +01:00
if ( empty ( $urltograb ))
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " URL " )), null , 'errors' );
$action = 'createcontainer' ;
}
2019-11-12 00:15:34 +01:00
elseif ( ! preg_match ( '/^http/' , $urltograb ))
2017-10-07 02:29:27 +02:00
{
2018-11-30 14:30:00 +01:00
$error ++ ;
2019-01-23 15:06:28 +01:00
$langs -> load ( " errors " );
2018-11-30 14:30:00 +01:00
setEventMessages ( 'Error URL must start with http:// or https://' , null , 'errors' );
$action = 'createcontainer' ;
2017-10-07 02:29:27 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-11-30 14:30:00 +01:00
{
// Clean url to grab, so url can be
// http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa
$urltograbwithoutdomainandparam = preg_replace ( '/^https?:\/\/[^\/]+\/?/i' , '' , $urltograb );
2019-08-14 01:43:06 +02:00
//$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb);
2018-11-30 14:30:00 +01:00
$urltograbwithoutdomainandparam = preg_replace ( '/\?.*$/' , '' , $urltograbwithoutdomainandparam );
2019-11-12 00:15:34 +01:00
if ( empty ( $urltograbwithoutdomainandparam ) && ! preg_match ( '/\/$/' , $urltograb ))
2018-11-30 14:30:00 +01:00
{
2019-11-12 00:15:34 +01:00
$urltograb .= '/' ;
2018-11-30 14:30:00 +01:00
}
2019-01-27 11:55:16 +01:00
$pageurl = dol_sanitizeFileName ( preg_replace ( '/[\/\.]/' , '-' , preg_replace ( '/\/+$/' , '' , $urltograbwithoutdomainandparam )));
2018-12-17 17:29:04 +01:00
2018-11-30 14:30:00 +01:00
$urltograbdirwithoutslash = dirname ( $urltograb . '.' );
$urltograbdirrootwithoutslash = getRootURLFromURL ( $urltograbdirwithoutslash );
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
// and $urltograbdirrootwithoutslash is https://www.dolimed.com
}
2017-08-20 18:50:51 +02:00
2018-02-19 14:56:37 +01:00
// Check pageurl is not already used
2018-02-19 18:07:59 +01:00
if ( $pageurl )
2017-10-07 13:09:31 +02:00
{
2018-02-19 18:07:59 +01:00
$tmpwebsitepage = new WebsitePage ( $db );
$result = $tmpwebsitepage -> fetch ( 0 , $object -> id , $pageurl );
if ( $result > 0 )
{
setEventMessages ( $langs -> trans ( " AliasPageAlreadyExists " , $pageurl ), null , 'errors' );
$error ++ ;
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2018-02-19 18:07:59 +01:00
}
2017-12-10 17:59:19 +01:00
}
2017-08-20 18:50:51 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-02-19 14:56:37 +01:00
{
$tmp = getURLContent ( $urltograb );
if ( $tmp [ 'curl_error_no' ])
2017-10-07 13:09:31 +02:00
{
2018-02-19 14:56:37 +01:00
$error ++ ;
setEventMessages ( 'Error getting ' . $urltograb . ': ' . $tmp [ 'curl_error_msg' ], null , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
2018-02-19 14:56:37 +01:00
elseif ( $tmp [ 'http_code' ] != '200' )
2017-10-07 13:09:31 +02:00
{
2018-02-19 14:56:37 +01:00
$error ++ ;
setEventMessages ( 'Error getting ' . $urltograb . ': ' . $tmp [ 'http_code' ], null , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-02-19 14:56:37 +01:00
// Remove comments
$tmp [ 'content' ] = removeHtmlComment ( $tmp [ 'content' ]);
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
$regs = array ();
2019-08-29 04:38:24 +02:00
preg_match ( '/<head>(.*)<\/head>/ims' , $tmp [ 'content' ], $regs );
$head = $regs [ 1 ];
2018-02-19 14:56:37 +01:00
$objectpage -> type_container = 'page' ;
$objectpage -> pageurl = $pageurl ;
if ( empty ( $objectpage -> pageurl ))
{
$tmpdomain = getDomainFromURL ( $urltograb );
2019-11-12 00:15:34 +01:00
$objectpage -> pageurl = $tmpdomain . '-home' ;
2018-02-19 14:56:37 +01:00
}
2017-10-07 13:09:31 +02:00
2018-02-28 14:36:22 +01:00
$objectpage -> aliasalt = '' ;
2019-08-29 04:38:24 +02:00
if ( preg_match ( '/^(\d+)\-/' , basename ( $urltograb ), $regs )) $objectpage -> aliasalt = $regs [ 1 ];
2019-11-12 00:15:34 +01:00
$regtmp = array ();
2018-02-19 14:56:37 +01:00
if ( preg_match ( '/<title>(.*)<\/title>/ims' , $head , $regtmp ))
2017-12-10 17:59:19 +01:00
{
2018-02-19 14:56:37 +01:00
$objectpage -> title = $regtmp [ 1 ];
2017-12-10 17:59:19 +01:00
}
2018-02-19 16:46:29 +01:00
if ( preg_match ( '/<meta name="title"[^"]+content="([^"]+)"/ims' , $head , $regtmp ))
{
2019-11-12 00:15:34 +01:00
if ( empty ( $objectpage -> title )) $objectpage -> title = $regtmp [ 1 ]; // If title not found into <title>, we get it from <meta title>
2018-02-19 16:46:29 +01:00
}
2018-02-19 14:56:37 +01:00
if ( preg_match ( '/<meta name="description"[^"]+content="([^"]+)"/ims' , $head , $regtmp ))
2017-12-10 17:59:19 +01:00
{
2018-02-19 14:56:37 +01:00
$objectpage -> description = $regtmp [ 1 ];
2017-12-10 17:59:19 +01:00
}
2018-02-19 14:56:37 +01:00
if ( preg_match ( '/<meta name="keywords"[^"]+content="([^"]+)"/ims' , $head , $regtmp ))
2017-10-07 13:09:31 +02:00
{
2018-02-19 14:56:37 +01:00
$objectpage -> keywords = $regtmp [ 1 ];
2017-10-07 13:09:31 +02:00
}
2018-02-19 14:56:37 +01:00
if ( preg_match ( '/<html\s+lang="([^"]+)"/ims' , $tmp [ 'content' ], $regtmp ))
2017-12-10 17:59:19 +01:00
{
2019-11-12 00:15:34 +01:00
$tmplang = explode ( '-' , $regtmp [ 1 ]);
2018-02-19 14:56:37 +01:00
$objectpage -> lang = $tmplang [ 0 ] . ( $tmplang [ 1 ] ? '_' . strtoupper ( $tmplang [ 1 ]) : '' );
2017-12-10 17:59:19 +01:00
}
2017-10-01 21:29:49 +02:00
2018-02-19 16:46:29 +01:00
$tmp [ 'content' ] = preg_replace ( '/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims' , '' , $tmp [ 'content' ]);
2018-02-19 14:56:37 +01:00
$objectpage -> content = $tmp [ 'content' ];
$objectpage -> content = preg_replace ( '/^.*<body(\s[^>]*)*>/ims' , '' , $objectpage -> content );
$objectpage -> content = preg_replace ( '/<\/body(\s[^>]*)*>.*$/ims' , '' , $objectpage -> content );
2019-11-12 00:15:34 +01:00
$absoluteurlinaction = $urltograbdirwithoutslash ;
2018-02-19 14:56:37 +01:00
// TODO Replace 'action="$urltograbdirwithoutslash' into action="/"
// TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..."
// TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/"
// TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..."
// Now loop to fetch all css files. Include them inline into header of page
$objectpage -> htmlheader = $tmp [ 'content' ];
$objectpage -> htmlheader = preg_replace ( '/^.*<head(\s[^>]*)*>/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<\/head(\s[^>]*)*>.*$/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<base(\s[^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
2018-02-19 16:46:29 +01:00
$objectpage -> htmlheader = preg_replace ( '/<meta http-equiv="content-type"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<meta name="robots"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<meta name="title"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<meta name="description"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<meta name="keywords"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<meta name="generator"([^>]*)*>\n*/ims' , '' , $objectpage -> htmlheader );
2018-02-19 14:56:37 +01:00
//$objectpage->htmlheader = preg_replace('/<meta name="verify-v1[^>]*>\n*/ims', '', $objectpage->htmlheader);
//$objectpage->htmlheader = preg_replace('/<meta name="msvalidate.01[^>]*>\n*/ims', '', $objectpage->htmlheader);
$objectpage -> htmlheader = preg_replace ( '/<title>[^<]*<\/title>\n*/ims' , '' , $objectpage -> htmlheader );
$objectpage -> htmlheader = preg_replace ( '/<link[^>]*rel="shortcut[^>]*>\n/ims' , '' , $objectpage -> htmlheader );
2020-05-19 00:50:30 +02:00
$objectpage -> htmlheader = preg_replace ( '/<link[^>]*rel="alternate[^>]*>\n/ims' , '' , $objectpage -> htmlheader );
2018-10-15 17:48:39 +02:00
$objectpage -> htmlheader = preg_replace ( '/<link[^>]*rel="canonical[^>]*>\n/ims' , '' , $objectpage -> htmlheader );
2018-02-19 14:56:37 +01:00
// Now loop to fetch JS
$tmp = $objectpage -> htmlheader ;
preg_match_all ( '/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i' , $objectpage -> htmlheader , $regs );
2018-11-30 14:30:00 +01:00
$errorforsubresource = 0 ;
2018-02-19 14:56:37 +01:00
foreach ( $regs [ 0 ] as $key => $val )
{
2019-08-29 04:38:24 +02:00
dol_syslog ( " We will grab the script resource found into script tag " . $regs [ 2 ][ $key ]);
2017-10-01 21:29:49 +02:00
2018-02-19 14:56:37 +01:00
$linkwithoutdomain = $regs [ 2 ][ $key ];
if ( preg_match ( '/^\//' , $regs [ 2 ][ $key ]))
{
2019-11-12 00:15:34 +01:00
$urltograbbis = $urltograbdirrootwithoutslash . $regs [ 2 ][ $key ]; // We use dirroot
2018-02-19 14:56:37 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$urltograbbis = $urltograbdirwithoutslash . '/' . $regs [ 2 ][ $key ]; // We use dir of grabbed file
2018-02-19 14:56:37 +01:00
}
2017-10-06 22:49:08 +02:00
2018-02-19 14:56:37 +01:00
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$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].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
2017-10-13 15:23:24 +02:00
2018-02-19 14:56:37 +01:00
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL ( $urltograbdirwithoutslash );
$domaintograbbis = getDomainFromURL ( $urltograbbis );
if ( $domaintograb != $domaintograbbis ) continue ;
/*
$tmpgeturl = getURLContent ( $urltograbbis );
if ( $tmpgeturl [ 'curl_error_no' ])
{
$error ++ ;
2018-11-30 14:30:00 +01:00
setEventMessages ( 'Error getting script url ' . $urltograbbis . ': ' . $tmpgeturl [ 'curl_error_msg' ], null , 'errors' );
$errorforsubresource ++ ;
2018-02-19 14:56:37 +01:00
$action = 'createcontainer' ;
}
elseif ( $tmpgeturl [ 'http_code' ] != '200' )
{
$error ++ ;
2018-11-30 14:30:00 +01:00
setEventMessages ( 'Error getting script url ' . $urltograbbis . ': ' . $tmpgeturl [ 'http_code' ], null , 'errors' );
$errorforsubresource ++ ;
2018-02-19 14:56:37 +01:00
$action = 'createcontainer' ;
}
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;
2019-01-27 11:55:16 +01:00
$tmp = preg_replace ( '/' . preg_quote ( $regs [ 0 ][ $key ], '/' ) . '/i' , '' , $tmp );
2017-12-10 17:59:19 +01:00
}
2018-02-19 16:46:29 +01:00
$objectpage -> htmlheader = trim ( $tmp ) . " \n " ;
2018-02-19 14:56:37 +01:00
2017-10-13 15:23:24 +02:00
2018-02-19 14:56:37 +01:00
// Now loop to fetch CSS
$pagecsscontent = " \n " . '<style>' . " \n " ;
preg_match_all ( '/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i' , $objectpage -> htmlheader , $regs );
2018-11-30 14:30:00 +01:00
$errorforsubresource = 0 ;
2018-02-19 14:56:37 +01:00
foreach ( $regs [ 0 ] as $key => $val )
2017-10-07 13:09:31 +02:00
{
2019-08-29 04:38:24 +02:00
dol_syslog ( " We will grab the css resources found into link tag " . $regs [ 2 ][ $key ]);
2017-10-07 13:09:31 +02:00
2018-02-19 14:56:37 +01:00
$linkwithoutdomain = $regs [ 2 ][ $key ];
if ( preg_match ( '/^\//' , $regs [ 2 ][ $key ]))
{
2019-11-12 00:15:34 +01:00
$urltograbbis = $urltograbdirrootwithoutslash . $regs [ 2 ][ $key ]; // We use dirroot
2018-02-19 14:56:37 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$urltograbbis = $urltograbdirwithoutslash . '/' . $regs [ 2 ][ $key ]; // We use dir of grabbed file
2018-02-19 14:56:37 +01:00
}
2017-10-13 15:23:24 +02:00
2018-02-19 14:56:37 +01:00
//$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$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].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
}
2017-10-13 15:23:24 +02:00
2018-02-19 14:56:37 +01:00
//print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - ';
//print $linkwithoutdomain.' - '.$urltograbbis."<br>\n";
// Test if this is an external URL of grabbed web site. If yes, we do not load resource
$domaintograb = getDomainFromURL ( $urltograbdirwithoutslash );
$domaintograbbis = getDomainFromURL ( $urltograbbis );
if ( $domaintograb != $domaintograbbis ) continue ;
$tmpgeturl = getURLContent ( $urltograbbis );
if ( $tmpgeturl [ 'curl_error_no' ])
{
2018-11-30 14:30:00 +01:00
$errorforsubresource ++ ;
setEventMessages ( 'Error getting link tag url ' . $urltograbbis . ': ' . $tmpgeturl [ 'curl_error_msg' ], null , 'errors' );
dol_syslog ( 'Error getting ' . $urltograbbis . ': ' . $tmpgeturl [ 'curl_error_msg' ]);
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2018-02-19 14:56:37 +01:00
}
elseif ( $tmpgeturl [ 'http_code' ] != '200' )
{
2018-11-30 14:30:00 +01:00
$errorforsubresource ++ ;
2019-08-19 18:39:40 +02:00
setEventMessages ( 'Error getting link tag url ' . $urltograbbis . ': ' . $tmpgeturl [ 'http_code' ], null , 'errors' );
2018-11-30 14:30:00 +01:00
dol_syslog ( 'Error getting ' . $urltograbbis . ': ' . $tmpgeturl [ 'curl_error_msg' ]);
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2018-02-19 14:56:37 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-08-29 04:38:24 +02:00
// Clean some comment
2019-08-29 13:17:14 +02:00
//$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1);
//$tmpgeturl['content'] = utf8_encode(utf8_decode($tmpgeturl['content']));
//$tmpgeturl['content'] = mb_convert_encoding($tmpgeturl['content'], 'UTF-8', 'UTF-8');
//$tmpgeturl['content'] = remove_bs($tmpgeturl['content']);
//$tmpgeturl['content'] = str_replace('$screen-md-max', 'auto', $tmpgeturl['content']);
//var_dump($tmpgeturl['content']);exit;
2019-08-29 04:38:24 +02:00
$tmpgeturl [ 'content' ] = preg_replace ( '/\/\*\s+CSS content[a-z\s]*\s+\*\//' , '' , $tmpgeturl [ 'content' ]);
2018-02-19 14:56:37 +01:00
//dol_mkdir(dirname($filetosave));
2017-10-07 13:09:31 +02:00
2018-02-19 14:56:37 +01:00
//$fp = fopen($filetosave, "w");
//fputs($fp, $tmpgeturl['content']);
//fclose($fp);
//if (! empty($conf->global->MAIN_UMASK))
// @chmod($file, octdec($conf->global->MAIN_UMASK));
2017-10-07 13:09:31 +02:00
2018-02-19 14:56:37 +01:00
// $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
2019-11-12 00:15:34 +01:00
$pagecsscontent .= '/* Content of file ' . $urltograbbis . ' */' . " \n " ;
2017-10-07 13:09:31 +02:00
2018-02-19 14:56:37 +01:00
getAllImages ( $object , $objectpage , $urltograbbis , $tmpgeturl [ 'content' ], $action , 1 , $grabimages , $grabimagesinto );
2017-10-07 13:09:31 +02:00
2019-08-29 04:38:24 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/lessc.class.php' ;
2019-09-06 10:36:49 +02:00
$lesscobj = new Lessc ();
2019-08-29 04:38:24 +02:00
try {
$contentforlessc = " .bodywebsite { \n " . $tmpgeturl [ 'content' ] . " \n } \n " ;
//print '<pre>'.$contentforlessc.'</pre>';
$contentforlessc = $lesscobj -> compile ( $contentforlessc );
//var_dump($contentforlessc); exit;
2019-11-12 00:15:34 +01:00
$pagecsscontent .= $contentforlessc . " \n " ;
2019-08-29 04:38:24 +02:00
//$pagecsscontent.=$tmpgeturl['content']."\n";
} catch ( exception $e ) {
//echo "failed to compile lessc";
2019-08-29 13:17:14 +02:00
dol_syslog ( " Failed to compile the CSS from URL " . $urltograbbis . " with lessc: " . $e -> getMessage (), LOG_WARNING );
2019-11-12 00:15:34 +01:00
$pagecsscontent .= $tmpgeturl [ 'content' ] . " \n " ;
2019-08-29 04:38:24 +02:00
}
2017-10-07 13:09:31 +02:00
2019-01-27 11:55:16 +01:00
$objectpage -> htmlheader = preg_replace ( '/' . preg_quote ( $regs [ 0 ][ $key ], '/' ) . '\n*/ims' , '' , $objectpage -> htmlheader );
2018-02-19 14:56:37 +01:00
}
2017-12-10 17:59:19 +01:00
}
2017-10-06 22:49:08 +02:00
2019-11-12 00:15:34 +01:00
$pagecsscontent .= '</style>' ;
2018-02-19 14:56:37 +01:00
//var_dump($pagecsscontent);
2017-10-06 22:49:08 +02:00
2018-02-19 14:56:37 +01:00
//print dol_escape_htmltag($tmp);exit;
2018-02-19 16:46:29 +01:00
$objectpage -> htmlheader .= trim ( $pagecsscontent ) . " \n " ;
2017-10-01 18:27:54 +02:00
2017-10-07 02:29:27 +02:00
2018-02-19 14:56:37 +01:00
// Now loop to fetch all images into page
$tmp = $objectpage -> content ;
2017-10-06 22:49:08 +02:00
2018-02-19 14:56:37 +01:00
getAllImages ( $object , $objectpage , $urltograb , $tmp , $action , 1 , $grabimages , $grabimagesinto );
2017-10-01 20:37:41 +02:00
2018-02-20 11:16:13 +01:00
// Normalize links href to Dolibarr internal naming
$tmp = preg_replace ( '/a href="\/([^\/"]+)\/([^\/"]+)"/' , 'a href="/\1-\2.php"' , $tmp );
$tmp = preg_replace ( '/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/' , 'a href="/\1-\2-\3.php"' , $tmp );
$tmp = preg_replace ( '/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/' , 'a href="/\1-\2-\3-\4.php"' , $tmp );
2018-02-19 14:56:37 +01:00
//print dol_escape_htmltag($tmp);exit;
$objectpage -> content = $tmp ;
2017-10-01 18:27:54 +02:00
2018-02-19 14:56:37 +01:00
$objectpage -> grabbed_from = $urltograb ;
}
2017-10-07 13:09:31 +02:00
}
}
2020-05-21 09:07:10 +02:00
else {
2020-02-20 01:08:53 +01:00
$objectpage -> title = GETPOST ( 'WEBSITE_TITLE' , 'alphanohtml' );
$objectpage -> type_container = GETPOST ( 'WEBSITE_TYPE_CONTAINER' , 'aZ09' );
2019-01-27 11:55:16 +01:00
$objectpage -> pageurl = GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' );
2020-02-20 01:08:53 +01:00
$objectpage -> aliasalt = GETPOST ( 'WEBSITE_ALIASALT' , 'alphanohtml' );
$objectpage -> description = GETPOST ( 'WEBSITE_DESCRIPTION' , 'alphanohtml' );
2019-01-27 11:55:16 +01:00
$objectpage -> lang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
2020-02-20 01:08:53 +01:00
$objectpage -> otherlang = GETPOST ( 'WEBSITE_OTHERLANG' , 'aZ09comma' );
$objectpage -> image = GETPOST ( 'WEBSITE_IMAGE' , 'alpha' );
$objectpage -> keywords = GETPOST ( 'WEBSITE_KEYWORDS' , 'alphanohtml' );
2019-01-27 11:55:16 +01:00
$objectpage -> htmlheader = GETPOST ( 'htmlheader' , 'none' );
2020-03-12 20:50:36 +01:00
$objectpage -> author_alias = GETPOST ( 'WEBSITE_AUTHORALIAS' , 'alphanohtml' );
2017-12-12 01:40:34 +01:00
2019-11-12 00:15:34 +01:00
$substitutionarray = array ();
$substitutionarray [ '__WEBSITE_CREATE_BY__' ] = $user -> getFullName ( $langs );
2018-01-07 22:04:31 +01:00
2019-01-27 11:55:16 +01:00
$sample = GETPOST ( 'sample' , 'alpha' );
2019-11-12 00:15:34 +01:00
if ( empty ( $sample )) $sample = 'empty' ;
2018-02-20 18:10:11 +01:00
2018-12-17 19:37:17 +01:00
$pathtosample = DOL_DOCUMENT_ROOT . '/website/samples/page-sample-' . $sample . '.html' ;
2018-02-20 18:10:11 +01:00
2018-01-07 22:04:31 +01:00
// Init content with content into pagetemplate.html, blogposttempltate.html, ...
2018-02-20 18:10:11 +01:00
$objectpage -> content = make_substitutions ( @ file_get_contents ( $pathtosample ), $substitutionarray );
2017-10-07 13:09:31 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
if ( empty ( $objectpage -> pageurl ))
{
2018-02-19 16:46:29 +01:00
$langs -> load ( " errors " );
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " WEBSITE_PAGENAME " )), null , 'errors' );
$error ++ ;
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
2019-11-12 00:15:34 +01:00
elseif ( ! preg_match ( '/^[a-z0-9\-\_]+$/i' , $objectpage -> pageurl ))
2017-10-07 13:09:31 +02:00
{
2018-02-19 16:46:29 +01:00
$langs -> load ( " errors " );
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> transnoentities ( " ErrorFieldCanNotContainSpecialCharacters " , $langs -> transnoentities ( 'WEBSITE_PAGENAME' )), null , 'errors' );
$error ++ ;
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
if ( empty ( $objectpage -> title ))
{
2018-02-19 16:46:29 +01:00
$langs -> load ( " errors " );
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " WEBSITE_TITLE " )), null , 'errors' );
$error ++ ;
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
2019-11-24 20:59:17 +01:00
$pageid = $objectpage -> create ( $user );
if ( $pageid <= 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
setEventMessages ( $objectpage -> error , $objectpage -> errors , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
2019-11-24 20:59:17 +01:00
else {
// If there is no home page yet, this new page will be set as the home page
if ( empty ( $object -> fk_default_home )) {
$object -> fk_default_home = $pageid ;
$res = $object -> update ( $user );
if ( $res <= 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-03-09 19:49:14 +01:00
} else {
$filetpl = $pathofwebsite . '/page' . $pageid . '.tpl.php' ;
2020-04-15 03:39:40 +02:00
// Generate the index.php page (to be the home page) and wrapper.php file
2020-03-09 19:49:14 +01:00
$result = dolSaveIndexPage ( $pathofwebsite , $fileindex , $filetpl , $filewrapper );
if ( $result <= 0 ) setEventMessages ( 'Failed to write file ' . $fileindex , null , 'errors' );
2019-11-24 20:59:17 +01:00
}
}
}
2017-10-07 13:09:31 +02:00
}
2019-11-24 20:59:17 +01:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
if ( ! empty ( $objectpage -> content ))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$filealias = $pathofwebsite . '/' . $objectpage -> pageurl . '.php' ;
$filetpl = $pathofwebsite . '/page' . $objectpage -> id . '.tpl.php' ;
2017-10-01 20:37:41 +02:00
2017-10-07 13:09:31 +02:00
// Save page alias
2019-11-12 00:15:34 +01:00
$result = dolSavePageAlias ( $filealias , $object , $objectpage );
if ( ! $result )
2019-08-14 16:28:41 +02:00
{
2020-02-21 11:36:16 +01:00
setEventMessages ( 'Failed to write file ' . basename ( $filealias ), null , 'errors' );
2019-08-14 16:28:41 +02:00
}
2017-10-07 13:09:31 +02:00
// Save page of content
2019-11-12 00:15:34 +01:00
$result = dolSavePageContent ( $filetpl , $object , $objectpage );
2017-10-07 13:09:31 +02:00
if ( $result )
{
setEventMessages ( $langs -> trans ( " Saved " ), null , 'mesgs' );
}
2020-05-21 09:07:10 +02:00
else {
2017-10-07 13:09:31 +02:00
setEventMessages ( 'Failed to write file ' . $filetpl , null , 'errors' );
2018-11-30 14:30:00 +01:00
$action = 'createcontainer' ;
2017-10-07 13:09:31 +02:00
}
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2016-04-23 21:34:10 +02:00
{
$db -> commit ();
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " PageAdded " , $objectpage -> pageurl ), null , 'mesgs' );
2019-11-12 00:15:34 +01:00
$action = '' ;
2016-04-23 21:34:10 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2016-04-23 21:34:10 +02:00
$db -> rollback ();
}
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-07-02 23:38:19 +02:00
{
2017-10-01 21:29:49 +02:00
$pageid = $objectpage -> id ;
2017-10-01 20:37:41 +02:00
2017-10-01 21:29:49 +02:00
// To generate the CSS, robot and htmlheader file.
2017-10-01 20:37:41 +02:00
2017-10-13 15:23:24 +02:00
// Check symlink to medias and restore it if ko
2019-11-12 00:15:34 +01:00
$pathtomedias = DOL_DATA_ROOT . '/medias' ;
$pathtomediasinwebsite = $pathofwebsite . '/medias' ;
if ( ! is_link ( dol_osencode ( $pathtomediasinwebsite )))
2017-10-13 15:23:24 +02:00
{
dol_syslog ( " Create symlink for " . $pathtomedias . " into name " . $pathtomediasinwebsite );
2019-11-12 00:15:34 +01:00
dol_mkdir ( dirname ( $pathtomediasinwebsite )); // To be sure dir for website exists
2017-10-13 15:23:24 +02:00
$result = symlink ( $pathtomedias , $pathtomediasinwebsite );
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filehtmlheader ))
2017-10-01 20:37:41 +02:00
{
2019-11-12 00:15:34 +01:00
$htmlheadercontent = " <html> \n " ;
$htmlheadercontent .= $htmlheadercontentdefault ;
$htmlheadercontent .= " </html> " ;
$result = dolSaveHtmlHeader ( $filehtmlheader , $htmlheadercontent );
2017-10-01 20:37:41 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filecss ))
2017-10-01 20:37:41 +02:00
{
2017-12-19 12:54:10 +01:00
$csscontent = " /* CSS content (all pages) */ \n body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; } \n .bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;} " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveCssFile ( $filecss , $csscontent );
2017-10-01 20:37:41 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filejs ))
2017-10-07 03:08:01 +02:00
{
$jscontent = " /* JS content (all pages) */ \n " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveJsFile ( $filejs , $jscontent );
2017-10-07 03:08:01 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filerobot ))
2017-10-01 20:37:41 +02:00
{
$robotcontent = " # Robot file. Generated with Dolibarr \n User-agent: * \n Allow: /public/ \n Disallow: /administrator/ " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveRobotFile ( $filerobot , $robotcontent );
2017-10-01 20:37:41 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filehtaccess ))
2017-10-01 20:37:41 +02:00
{
$htaccesscontent = " # Order allow,deny \n # Deny from all " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveHtaccessFile ( $filehtaccess , $htaccesscontent );
2017-10-01 20:37:41 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filemanifestjson ))
2019-08-12 17:34:18 +02:00
{
$manifestjsoncontent = " " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveManifestJson ( $filemanifestjson , $manifestjsoncontent );
2019-08-12 17:34:18 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! dol_is_file ( $filereadme ))
2019-08-15 00:55:47 +02:00
{
$readmecontent = " Website generated by Dolibarr ERP CRM " ;
2019-11-12 00:15:34 +01:00
$result = dolSaveReadme ( $filereadme , $readmecontent );
2019-08-15 00:55:47 +02:00
}
2019-08-12 17:34:18 +02:00
2017-10-01 20:37:41 +02:00
$action = 'preview' ;
2017-07-02 23:38:19 +02:00
}
2016-04-23 21:34:10 +02:00
}
2018-09-08 12:04:40 +02:00
// Delete site
2019-06-02 17:27:00 +02:00
if ( $action == 'confirm_deletesite' && $confirm == 'yes' )
2018-09-08 12:04:40 +02:00
{
$error = 0 ;
$db -> begin ();
2019-06-02 17:27:00 +02:00
$res = $object -> fetch ( GETPOST ( 'id' , 'int' ));
2018-09-08 12:04:40 +02:00
$website = $object ;
if ( $res > 0 )
{
$res = $object -> delete ( $user );
if ( $res <= 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-06-02 17:27:00 +02:00
{
if ( GETPOST ( 'delete_also_js' , 'alpha' ) == 'on' )
{
2019-11-12 00:15:34 +01:00
$pathofwebsitejs = DOL_DATA_ROOT . '/medias/js/' . $object -> ref ;
2019-06-02 17:27:00 +02:00
dol_delete_dir_recursive ( $pathofwebsitejs );
}
if ( GETPOST ( 'delete_also_medias' , 'alpha' ) == 'on' )
{
2019-11-12 00:15:34 +01:00
$pathofwebsitemedias = DOL_DATA_ROOT . '/medias/image/' . $object -> ref ;
2019-06-02 17:27:00 +02:00
dol_delete_dir_recursive ( $pathofwebsitemedias );
}
}
2018-09-08 12:04:40 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-09-08 12:04:40 +02:00
{
$db -> commit ();
2019-06-02 17:27:00 +02:00
setEventMessages ( $langs -> trans ( " SiteDeleted " , $object -> ref ), null , 'mesgs' );
2018-09-08 12:04:40 +02:00
2019-06-02 17:27:00 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id );
2018-09-08 12:04:40 +02:00
exit ;
}
2020-05-21 09:07:10 +02:00
else {
2018-09-08 12:04:40 +02:00
$db -> rollback ();
dol_print_error ( $db );
}
}
2017-10-07 02:29:27 +02:00
// Delete page
2016-05-01 17:01:38 +02:00
if ( $action == 'delete' )
{
2018-02-15 00:01:25 +01:00
$error = 0 ;
2017-10-07 13:09:31 +02:00
$db -> begin ();
2016-05-01 17:01:38 +02:00
2018-07-22 17:18:35 +02:00
$res = $object -> fetch ( 0 , $websitekey );
$website = $object ;
2016-05-01 17:01:38 +02:00
2017-10-07 13:09:31 +02:00
$res = $objectpage -> fetch ( $pageid , $object -> fk_website );
2016-05-01 17:01:38 +02:00
2017-10-07 13:09:31 +02:00
if ( $res > 0 )
{
$res = $objectpage -> delete ( $user );
2018-02-15 00:01:25 +01:00
if ( $res <= 0 )
2017-10-07 13:09:31 +02:00
{
$error ++ ;
setEventMessages ( $objectpage -> error , $objectpage -> errors , 'errors' );
}
2018-02-15 00:01:25 +01:00
}
2016-05-01 17:01:38 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-02-15 00:01:25 +01:00
{
$db -> commit ();
2018-07-22 17:18:35 +02:00
setEventMessages ( $langs -> trans ( " PageDeleted " , $objectpage -> pageurl , $websitekey ), null , 'mesgs' );
2017-07-02 23:38:19 +02:00
2018-07-22 17:18:35 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $websitekey );
2018-02-15 00:01:25 +01:00
exit ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-02-15 00:01:25 +01:00
$db -> rollback ();
2017-10-07 13:09:31 +02:00
dol_print_error ( $db );
}
2016-05-01 17:01:38 +02:00
}
2020-02-27 22:58:36 +01:00
// Update css Update site properties
2016-05-01 16:34:50 +02:00
if ( $action == 'updatecss' )
2016-04-23 21:34:10 +02:00
{
2019-09-02 18:43:22 +02:00
// If we tried to reload another site/page, we stay on editcss mode.
2019-11-12 00:15:34 +01:00
if ( GETPOST ( 'refreshsite' ) || GETPOST ( 'refreshsite_x' ) || GETPOST ( 'refreshsite.x' ) || GETPOST ( 'refreshpage' ) || GETPOST ( 'refreshpage_x' ) || GETPOST ( 'refreshpage.x' ))
2017-07-19 16:38:00 +02:00
{
2019-11-12 00:15:34 +01:00
$action = 'editcss' ;
2017-07-19 16:38:00 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-07-22 17:18:35 +02:00
$res = $object -> fetch ( 0 , $websitekey );
$website = $object ;
2017-07-19 16:38:00 +02:00
2019-01-23 14:57:43 +01:00
if ( GETPOSTISSET ( 'virtualhost' ))
{
2020-05-19 00:50:30 +02:00
$tmpvirtualhost = preg_replace ( '/\/$/' , '' , GETPOST ( 'virtualhost' , 'alpha' ));
if ( $tmpvirtualhost && ! preg_match ( '/^http/' , $tmpvirtualhost ))
2019-01-23 14:57:43 +01:00
{
$error ++ ;
2019-01-23 15:06:28 +01:00
setEventMessages ( $langs -> trans ( 'ErrorURLMustStartWithHttp' , $langs -> transnoentitiesnoconv ( " VirtualHost " )), null , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'editcss' ;
2019-01-23 14:57:43 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-01-23 14:57:43 +01:00
{
2020-04-10 10:59:32 +02:00
$arrayotherlang = explode ( ',' , GETPOST ( 'WEBSITE_OTHERLANG' , 'alphanohtml' ));
foreach ( $arrayotherlang as $key => $val ) {
$arrayotherlang [ $key ] = substr ( trim ( $val ), 0 , 2 ); // Kept short language code only
2020-02-27 22:58:36 +01:00
}
2020-05-19 00:50:30 +02:00
$object -> virtualhost = $tmpvirtualhost ;
2020-02-19 18:32:04 +01:00
$object -> lang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
2020-02-27 22:58:36 +01:00
$object -> otherlang = join ( ',' , $arrayotherlang );
2019-12-07 13:09:55 +01:00
$object -> use_manifest = GETPOST ( 'use_manifest' , 'alpha' );
2019-01-23 14:57:43 +01:00
$result = $object -> update ( $user );
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'editcss' ;
2019-01-23 14:57:43 +01:00
}
}
}
2018-11-30 14:46:44 +01:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-01-23 14:57:43 +01:00
{
// Save master.inc.php file
dol_syslog ( " Save master file " . $filemaster );
2018-11-30 14:46:44 +01:00
2019-01-23 14:57:43 +01:00
dol_mkdir ( $pathofwebsite );
2018-11-30 14:46:44 +01:00
2019-01-23 14:57:43 +01:00
// Now generate the master.inc.php page
$result = dolSaveMasterFile ( $filemaster );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-08-14 16:28:41 +02:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filemaster , null , 'errors' );
}
2018-12-17 17:29:04 +01:00
2017-07-21 20:16:53 +02:00
2019-01-23 14:57:43 +01:00
// Html header file
2019-11-12 00:15:34 +01:00
$htmlheadercontent = '' ;
2017-07-21 20:16:53 +02:00
2019-01-23 14:57:43 +01:00
/* We disable php code since htmlheader is never executed as an include but only read by fgets_content .
$htmlheadercontent .= " <?php // BEGIN PHP \n " ;
2019-03-06 14:33:05 +01:00
$htmlheadercontent .= '$websitekey=basename(__DIR__);' . " \n " ;
2019-08-12 17:34:18 +02:00
$htmlheadercontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded " . " \n " ;
2019-01-23 14:57:43 +01:00
$htmlheadercontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$htmlheadercontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$htmlheadercontent .= " ob_start(); \n " ;
// $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page
$htmlheadercontent .= " // END PHP ?> \n " ; */
2017-07-19 16:38:00 +02:00
2019-11-12 00:15:34 +01:00
$htmlheadercontent .= preg_replace ( array ( '/<html>\n*/ims' , '/<\/html>\n*/ims' ), array ( '' , '' ), GETPOST ( 'WEBSITE_HTML_HEADER' , 'none' ));
2017-07-21 20:16:53 +02:00
2019-01-23 14:57:43 +01:00
/* $htmlheadercontent .= " \n " . '<?php // BEGIN PHP' . " \n " ;
$htmlheadercontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);' . " \n " ;
$htmlheadercontent .= " // END PHP ?> " . " \n " ; */
2017-08-21 04:17:28 +02:00
2019-01-23 14:57:43 +01:00
$htmlheadercontent = trim ( $htmlheadercontent ) . " \n " ;
2017-07-19 16:38:00 +02:00
2019-08-14 16:28:41 +02:00
$result = dolSaveHtmlHeader ( $filehtmlheader , $htmlheadercontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-08-14 16:28:41 +02:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filehtmlheader , null , 'errors' );
}
2017-07-19 16:38:00 +02:00
2017-07-21 20:16:53 +02:00
2019-01-23 14:57:43 +01:00
// Css file
2019-11-12 00:15:34 +01:00
$csscontent = '' ;
$csscontent .= " <?php // BEGIN PHP \n " ;
$csscontent .= '$websitekey=basename(__DIR__);' . " \n " ;
2020-04-26 23:52:23 +02:00
$csscontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded \n " ; // For the css, we need to set path of master using the dirname of css file.
2019-11-12 00:15:34 +01:00
$csscontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$csscontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$csscontent .= " ob_start(); \n " ;
$csscontent .= " if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n " ;
$csscontent .= " header('Cache-Control: max-age=3600, public, must-revalidate'); \n " ;
$csscontent .= " header('Content-type: text/css'); \n " ;
$csscontent .= " } \n " ;
$csscontent .= " // END PHP ?> \n " ;
$csscontent .= trim ( GETPOST ( 'WEBSITE_CSS_INLINE' , 'none' )) . " \n " ;
$csscontent .= '<?php // BEGIN PHP' . " \n " ;
$csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");' . " \n " ;
2020-04-26 23:52:23 +02:00
$csscontent .= " // END PHP ?> \n " ;
2017-07-19 16:38:00 +02:00
2019-01-23 14:57:43 +01:00
dol_syslog ( " Save css content into " . $filecss );
2017-07-19 16:38:00 +02:00
2019-08-14 16:28:41 +02:00
$result = dolSaveCssFile ( $filecss , $csscontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-01-23 14:57:43 +01:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filecss , null , 'errors' );
}
2017-07-19 16:38:00 +02:00
2017-10-07 03:08:01 +02:00
2019-01-23 14:57:43 +01:00
// Js file
2019-11-12 00:15:34 +01:00
$jscontent = '' ;
2017-10-07 03:08:01 +02:00
2019-11-12 00:15:34 +01:00
$jscontent .= " <?php // BEGIN PHP \n " ;
$jscontent .= '$websitekey=basename(__DIR__);' . " \n " ;
2020-04-27 00:02:31 +02:00
$jscontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded \n " ; // For the css, we need to set path of master using the dirname of css file.
2019-11-12 00:15:34 +01:00
$jscontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$jscontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$jscontent .= " ob_start(); \n " ;
$jscontent .= " header('Cache-Control: max-age=3600, public, must-revalidate'); \n " ;
$jscontent .= " header('Content-type: application/javascript'); \n " ;
$jscontent .= " // END PHP ?> \n " ;
2017-10-07 03:08:01 +02:00
2019-11-12 00:15:34 +01:00
$jscontent .= trim ( GETPOST ( 'WEBSITE_JS_INLINE' , 'none' )) . " \n " ;
2017-10-07 03:08:01 +02:00
2019-11-12 00:15:34 +01:00
$jscontent .= '<?php // BEGIN PHP' . " \n " ;
$jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");' . " \n " ;
2020-04-27 00:02:31 +02:00
$jscontent .= " // END PHP ?> \n " ;
2017-10-07 03:08:01 +02:00
2019-08-14 16:28:41 +02:00
$result = dolSaveJsFile ( $filejs , $jscontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-01-23 14:57:43 +01:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filejs , null , 'errors' );
}
2017-10-07 03:08:01 +02:00
2017-07-23 17:44:26 +02:00
2019-01-23 14:57:43 +01:00
// Robot file
2019-11-12 00:15:34 +01:00
$robotcontent = '' ;
2017-07-23 17:44:26 +02:00
2019-01-23 14:57:43 +01:00
/* $robotcontent .= " <?php // BEGIN PHP \n " ;
2019-03-06 14:33:05 +01:00
$robotcontent .= '$websitekey=basename(__DIR__);' . " \n " ;
2019-08-12 17:34:18 +02:00
$robotcontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded " . " \n " ;
2019-01-23 14:57:43 +01:00
$robotcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$robotcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$robotcontent .= " ob_start(); \n " ;
$robotcontent .= " header('Cache-Control: max-age=3600, public, must-revalidate'); \n " ;
$robotcontent .= " header('Content-type: text/css'); \n " ;
$robotcontent .= " // END PHP ?> \n " ; */
2017-07-23 17:44:26 +02:00
2019-11-12 00:15:34 +01:00
$robotcontent .= trim ( GETPOST ( 'WEBSITE_ROBOT' , 'none' )) . " \n " ;
2017-07-23 17:44:26 +02:00
2019-01-23 14:57:43 +01:00
/* $robotcontent .= " \n " . '<?php // BEGIN PHP' . " \n " ;
2019-08-13 06:37:06 +02:00
$robotcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");' . " \n " ;
2019-01-23 14:57:43 +01:00
$robotcontent .= " // END PHP ?> " . " \n " ; */
2017-07-23 17:44:26 +02:00
2019-08-14 16:28:41 +02:00
$result = dolSaveRobotFile ( $filerobot , $robotcontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-01-23 14:57:43 +01:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filerobot , null , 'errors' );
}
2017-07-23 17:44:26 +02:00
2019-08-12 17:34:18 +02:00
// Htaccess file
2019-11-12 00:15:34 +01:00
$htaccesscontent = '' ;
$htaccesscontent .= trim ( GETPOST ( 'WEBSITE_HTACCESS' , 'none' )) . " \n " ;
2019-01-23 14:57:43 +01:00
2019-08-14 16:28:41 +02:00
$result = dolSaveHtaccessFile ( $filehtaccess , $htaccesscontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-08-14 16:28:41 +02:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filehtaccess , null , 'errors' );
}
2017-07-23 17:44:26 +02:00
2019-08-12 17:34:18 +02:00
// manifest.json file
2019-11-12 00:15:34 +01:00
$manifestjsoncontent = '' ;
2019-08-12 17:34:18 +02:00
2019-11-12 00:15:34 +01:00
$manifestjsoncontent .= " <?php // BEGIN PHP \n " ;
$manifestjsoncontent .= '$websitekey=basename(__DIR__);' . " \n " ;
2020-04-27 00:02:31 +02:00
$manifestjsoncontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded \n " ; // For the css, we need to set path of master using the dirname of css file.
2019-11-12 00:15:34 +01:00
$manifestjsoncontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$manifestjsoncontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$manifestjsoncontent .= " ob_start(); \n " ;
$manifestjsoncontent .= " header('Cache-Control: max-age=3600, public, must-revalidate'); \n " ;
$manifestjsoncontent .= " header('Content-type: application/manifest+json'); \n " ;
$manifestjsoncontent .= " // END PHP ?> \n " ;
2019-08-12 17:34:18 +02:00
2019-11-12 00:15:34 +01:00
$manifestjsoncontent .= trim ( GETPOST ( 'WEBSITE_MANIFEST_JSON' , 'none' )) . " \n " ;
2019-08-12 17:34:18 +02:00
2019-11-12 00:15:34 +01:00
$manifestjsoncontent .= '<?php // BEGIN PHP' . " \n " ;
$manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");' . " \n " ;
2020-04-27 00:02:31 +02:00
$manifestjsoncontent .= " // END PHP ?> \n " ;
2019-08-12 17:34:18 +02:00
2019-08-14 16:28:41 +02:00
$result = dolSaveManifestJson ( $filemanifestjson , $manifestjsoncontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-08-14 16:28:41 +02:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filemanifestjson , null , 'errors' );
}
2019-08-12 17:34:18 +02:00
2019-08-15 00:55:47 +02:00
// README.md file
2019-11-12 00:15:34 +01:00
$readmecontent = '' ;
2019-08-15 00:55:47 +02:00
/* $readmecontent .= " <?php // BEGIN PHP \n " ;
$readmecontent .= '$websitekey=basename(__DIR__);' . " \n " ;
$readmecontent .= " if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded " . " \n " ; // For the css, we need to set path of master using the dirname of css file.
$readmecontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; \n " ;
$readmecontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php'; \n " ;
$readmecontent .= " ob_start(); \n " ;
$readmecontent .= " header('Cache-Control: max-age=3600, public, must-revalidate'); \n " ;
$readmecontent .= " header('Content-type: application/manifest+json'); \n " ;
$readmecontent .= " // END PHP ?> \n " ; */
2019-11-12 00:15:34 +01:00
$readmecontent .= trim ( GETPOST ( 'WEBSITE_README' , 'none' )) . " \n " ;
2019-08-15 00:55:47 +02:00
/* $readmecontent .= '<?php // BEGIN PHP' . " \n " ;
$readmecontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");' . " \n " ;
$readmecontent .= " // END PHP ?> " . " \n " ; */
$result = dolSaveReadme ( $filereadme , $readmecontent );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2019-08-15 00:55:47 +02:00
{
$error ++ ;
setEventMessages ( 'Failed to write file ' . $filereadme , null , 'errors' );
}
2020-05-23 13:10:33 +02:00
// Save wrapper.php
$result = dolSaveIndexPage ( $pathofwebsite , '' , '' , $filewrapper );
2019-01-23 14:57:43 +01:00
// Message if no error
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-01-23 14:57:43 +01:00
{
setEventMessages ( $langs -> trans ( " Saved " ), null , 'mesgs' );
}
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'updateandstay' )) // If we click on "Save And Stay", we don not make the redirect
2019-10-21 00:55:52 +02:00
{
2019-11-12 00:15:34 +01:00
$action = 'preview' ;
2019-10-21 00:55:52 +02:00
if ( $backtopage )
{
header ( " Location: " . $backtopage );
exit ;
}
}
2020-05-21 09:07:10 +02:00
else {
2019-10-21 00:55:52 +02:00
$action = 'editcss' ;
2019-09-02 18:43:22 +02:00
}
2017-10-07 13:09:31 +02:00
}
2017-07-19 16:38:00 +02:00
}
2016-05-01 16:34:50 +02:00
}
2016-05-02 15:51:18 +02:00
// Update page
if ( $action == 'setashome' )
{
2017-10-07 13:09:31 +02:00
$db -> begin ();
2018-07-22 17:18:35 +02:00
$object -> fetch ( 0 , $websitekey );
$website = $object ;
2017-10-07 13:09:31 +02:00
$object -> fk_default_home = $pageid ;
$res = $object -> update ( $user );
2019-11-12 00:15:34 +01:00
if ( ! $res > 0 )
2017-10-07 13:09:31 +02:00
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
$db -> commit ();
2020-03-09 19:49:14 +01:00
$filetpl = $pathofwebsite . '/page' . $pageid . '.tpl.php' ;
2017-10-07 13:09:31 +02:00
// Generate the index.php page to be the home page
2018-09-09 14:05:23 +02:00
$result = dolSaveIndexPage ( $pathofwebsite , $fileindex , $filetpl , $filewrapper );
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
if ( $result ) setEventMessages ( $langs -> trans ( " Saved " ), null , 'mesgs' );
else setEventMessages ( 'Failed to write file ' . $fileindex , null , 'errors' );
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
$action = 'preview' ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2017-10-07 13:09:31 +02:00
$db -> rollback ();
}
2016-05-02 15:51:18 +02:00
}
2016-09-15 19:27:04 +02:00
// Update page (meta)
2016-05-01 16:34:50 +02:00
if ( $action == 'updatemeta' )
{
2017-10-07 13:09:31 +02:00
$db -> begin ();
2018-02-19 16:46:29 +01:00
2018-08-20 19:10:33 +02:00
$result = $object -> fetch ( 0 , $websitekey );
2018-07-22 17:18:35 +02:00
$website = $object ;
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
$objectpage -> fk_website = $object -> id ;
2016-05-01 16:34:50 +02:00
2017-07-21 02:30:02 +02:00
// Check parameters
2019-11-12 00:15:34 +01:00
if ( ! preg_match ( '/^[a-z0-9\-\_]+$/i' , GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' )))
2017-10-07 13:09:31 +02:00
{
$error ++ ;
2018-02-19 16:46:29 +01:00
$langs -> load ( " errors " );
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> transnoentities ( " ErrorFieldCanNotContainSpecialCharacters " , $langs -> transnoentities ( 'WEBSITE_PAGENAME' )), null , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'editmeta' ;
2017-10-07 13:09:31 +02:00
}
2016-04-27 09:41:42 +02:00
2018-08-20 19:10:33 +02:00
$res = $objectpage -> fetch ( $pageid , $object -> id );
2017-10-07 13:09:31 +02:00
if ( $res <= 0 )
{
$error ++ ;
2018-02-19 16:46:29 +01:00
setEventMessages ( 'Page not found ' . $objectpage -> error , $objectpage -> errors , 'errors' );
2017-10-07 13:09:31 +02:00
}
2016-08-08 18:25:37 +02:00
2018-08-20 19:10:33 +02:00
// Check alias not exists
2019-11-12 00:15:34 +01:00
if ( ! $error && GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' ))
2018-08-20 19:10:33 +02:00
{
2019-11-12 00:15:34 +01:00
$websitepagetemp = new WebsitePage ( $db );
2018-08-20 19:10:33 +02:00
$result = $websitepagetemp -> fetch ( - 1 * $objectpage -> id , $object -> id , GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' ));
if ( $result < 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $websitepagetemp -> error , $websitepagetemp -> errors , 'errors' );
$action = 'editmeta' ;
}
if ( $result > 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorAPageWithThisNameOrAliasAlreadyExists " , $websitepagetemp -> pageurl ), null , 'errors' );
$action = 'editmeta' ;
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error && GETPOST ( 'WEBSITE_ALIASALT' , 'alpha' ))
2018-08-20 19:10:33 +02:00
{
2019-11-12 00:15:34 +01:00
$arrayofaliastotest = explode ( ',' , GETPOST ( 'WEBSITE_ALIASALT' , 'alpha' ));
$websitepagetemp = new WebsitePage ( $db );
foreach ( $arrayofaliastotest as $aliastotest )
2018-08-20 19:10:33 +02:00
{
$result = $websitepagetemp -> fetch ( - 1 * $objectpage -> id , $object -> id , $aliastotest );
if ( $result < 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $websitepagetemp -> error , $websitepagetemp -> errors , 'errors' );
$action = 'editmeta' ;
break ;
}
if ( $result > 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorAPageWithThisNameOrAliasAlreadyExists " , $websitepagetemp -> pageurl ), null , 'errors' );
$action = 'editmeta' ;
break ;
}
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
$objectpage -> old_object = clone $objectpage ;
2016-09-16 01:23:54 +02:00
2020-02-19 18:32:04 +01:00
$objectpage -> title = GETPOST ( 'WEBSITE_TITLE' , 'alphanohtml' );
$objectpage -> type_container = GETPOST ( 'WEBSITE_TYPE_CONTAINER' , 'alphanohtml' );
2017-10-07 13:09:31 +02:00
$objectpage -> pageurl = GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' );
2018-02-28 14:36:22 +01:00
$objectpage -> aliasalt = GETPOST ( 'WEBSITE_ALIASALT' , 'alpha' );
2020-02-19 18:32:04 +01:00
$objectpage -> lang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
$objectpage -> otherlang = GETPOST ( 'WEBSITE_OTHERLANG' , 'aZ09comma' );
$objectpage -> description = GETPOST ( 'WEBSITE_DESCRIPTION' , 'alphanohtml' );
2018-11-20 18:29:29 +01:00
$objectpage -> image = GETPOST ( 'WEBSITE_IMAGE' , 'alpha' );
2020-02-20 01:08:53 +01:00
$objectpage -> keywords = GETPOST ( 'WEBSITE_KEYWORDS' , 'alphanohtml' );
2018-02-19 16:46:29 +01:00
$objectpage -> htmlheader = trim ( GETPOST ( 'htmlheader' , 'none' ));
2019-11-16 12:43:32 +01:00
$objectpage -> fk_page = ( GETPOST ( 'pageidfortranslation' , 'int' ) > 0 ? GETPOST ( 'pageidfortranslation' , 'int' ) : 0 );
2020-03-12 20:50:36 +01:00
$objectpage -> author_alias = trim ( GETPOST ( 'WEBSITE_AUTHORALIAS' , 'alphanohtml' ));
2019-10-31 21:09:33 +01:00
2019-11-12 00:15:34 +01:00
$newdatecreation = dol_mktime ( GETPOST ( 'datecreationhour' , 'int' ), GETPOST ( 'datecreationmin' , 'int' ), GETPOST ( 'datecreationsec' , 'int' ), GETPOST ( 'datecreationmonth' , 'int' ), GETPOST ( 'datecreationday' , 'int' ), GETPOST ( 'datecreationyear' , 'int' ));
2019-01-15 10:53:28 +01:00
if ( $newdatecreation ) $objectpage -> date_creation = $newdatecreation ;
2016-09-16 01:00:24 +02:00
2017-10-07 13:09:31 +02:00
$res = $objectpage -> update ( $user );
2019-11-12 00:15:34 +01:00
if ( ! ( $res > 0 ))
2017-10-07 13:09:31 +02:00
{
2018-08-20 19:10:33 +02:00
$langs -> load ( " errors " );
if ( $db -> lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorAPageWithThisNameOrAliasAlreadyExists " ), null , 'errors' );
$action = 'editmeta' ;
}
2020-05-21 09:07:10 +02:00
else {
2018-08-20 19:10:33 +02:00
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $objectpage -> error , $objectpage -> errors , 'errors' );
$action = 'editmeta' ;
}
2017-10-07 13:09:31 +02:00
}
2018-02-19 16:46:29 +01:00
}
2017-07-02 23:38:19 +02:00
2020-05-26 00:19:32 +02:00
if ( ! $error ) {
// Supplier categories association
$categoriesarray = GETPOST ( 'categories' , 'array' );
2020-05-26 01:07:09 +02:00
$result = $objectpage -> setCategories ( $categoriesarray );
2020-05-26 00:19:32 +02:00
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-02-19 16:46:29 +01:00
{
$db -> commit ();
}
2020-05-21 09:07:10 +02:00
else {
2018-02-19 16:46:29 +01:00
$db -> rollback ();
}
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-02-19 16:46:29 +01:00
{
2019-11-12 00:15:34 +01:00
$filemaster = $pathofwebsite . '/master.inc.php' ;
$fileoldalias = $pathofwebsite . '/' . $objectpage -> old_object -> pageurl . '.php' ;
$filealias = $pathofwebsite . '/' . $objectpage -> pageurl . '.php' ;
2017-07-02 23:38:19 +02:00
2018-02-19 16:46:29 +01:00
dol_mkdir ( $pathofwebsite );
2017-07-02 23:38:19 +02:00
2018-02-19 16:46:29 +01:00
// Now generate the master.inc.php page
2018-09-10 23:20:31 +02:00
$result = dolSaveMasterFile ( $filemaster );
2019-11-12 00:15:34 +01:00
if ( ! $result ) setEventMessages ( 'Failed to write file ' . $filemaster , null , 'errors' );
2017-10-07 13:09:31 +02:00
2018-06-14 16:33:11 +02:00
// Now delete the alias.php page
2019-11-12 00:15:34 +01:00
if ( ! empty ( $fileoldalias ))
2018-02-19 16:46:29 +01:00
{
2018-06-14 16:33:11 +02:00
dol_syslog ( " We delete old alias page name= " . $fileoldalias . " to build a new alias page= " . $filealias );
2018-02-19 16:46:29 +01:00
dol_delete_file ( $fileoldalias );
}
2018-06-14 16:33:11 +02:00
// Now delete the alternative alias.php pages
2019-11-12 00:15:34 +01:00
if ( ! empty ( $objectpage -> old_object -> aliasalt ))
2018-06-14 16:33:11 +02:00
{
2019-11-12 00:15:34 +01:00
$tmpaltaliases = explode ( ',' , $objectpage -> old_object -> aliasalt );
2018-06-14 16:33:11 +02:00
if ( is_array ( $tmpaltaliases ))
{
2019-11-12 00:15:34 +01:00
foreach ( $tmpaltaliases as $tmpaliasalt )
2018-06-14 16:33:11 +02:00
{
dol_syslog ( " We delete old alt alias pages name= " . trim ( $tmpaliasalt ));
dol_delete_file ( $pathofwebsite . '/' . trim ( $tmpaliasalt ) . '.php' );
}
}
}
2016-08-08 18:25:37 +02:00
2018-02-19 16:46:29 +01:00
// Save page alias
2019-11-12 00:15:34 +01:00
$result = dolSavePageAlias ( $filealias , $object , $objectpage );
if ( ! $result ) setEventMessages ( 'Failed to write file ' . $filealias , null , 'errors' );
2018-06-14 16:33:11 +02:00
// Save alt aliases
2019-11-12 00:15:34 +01:00
if ( ! empty ( $objectpage -> aliasalt ))
2018-06-14 16:33:11 +02:00
{
2019-11-12 00:15:34 +01:00
$tmpaltaliases = explode ( ',' , $objectpage -> aliasalt );
2018-06-14 16:33:11 +02:00
if ( is_array ( $tmpaltaliases ))
{
2019-11-12 00:15:34 +01:00
foreach ( $tmpaltaliases as $tmpaliasalt )
2018-06-14 16:33:11 +02:00
{
2019-08-16 02:31:06 +02:00
if ( trim ( $tmpaliasalt ))
{
2020-02-21 11:36:16 +01:00
$filealias = $pathofwebsite . '/' . trim ( $tmpaliasalt ) . '.php' ;
$result = dolSavePageAlias ( $filealias , $object , $objectpage );
if ( ! $result ) setEventMessages ( 'Failed to write file ' . basename ( $filealias ), null , 'errors' );
2019-08-16 02:31:06 +02:00
}
2018-06-14 16:33:11 +02:00
}
}
}
2017-10-07 13:09:31 +02:00
2018-02-19 16:46:29 +01:00
// Save page of content
2019-11-12 00:15:34 +01:00
$result = dolSavePageContent ( $filetpl , $object , $objectpage );
2018-02-19 16:46:29 +01:00
if ( $result )
{
setEventMessages ( $langs -> trans ( " Saved " ), null , 'mesgs' );
2019-12-08 15:57:51 +01:00
if ( ! GETPOSTISSET ( 'updateandstay' )) // If we click on "Save And Stay", we do not make the redirect
{
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid);
//exit;
$action = 'preview' ;
}
2020-05-21 09:07:10 +02:00
else {
2019-12-08 15:57:51 +01:00
$action = 'editmeta' ;
}
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-02-19 16:46:29 +01:00
setEventMessages ( 'Failed to write file ' . $filetpl , null , 'errors' );
2018-07-22 17:18:35 +02:00
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid);
2018-02-19 16:46:29 +01:00
//exit;
2019-12-08 15:57:51 +01:00
$action = 'preview' ;
2017-10-07 13:09:31 +02:00
}
}
2016-05-01 16:34:50 +02:00
}
2016-04-23 21:34:10 +02:00
// Update page
2017-08-03 01:45:31 +02:00
if (( $action == 'updatesource' || $action == 'updatecontent' || $action == 'confirm_createfromclone' || $action == 'confirm_createpagefromclone' )
2017-07-21 13:38:13 +02:00
|| ( $action == 'preview' && ( GETPOST ( 'refreshsite' ) || GETPOST ( 'refreshpage' ) || GETPOST ( 'preview' ))))
2016-04-23 21:34:10 +02:00
{
2018-07-22 17:18:35 +02:00
$object -> fetch ( 0 , $websitekey );
$website = $object ;
2016-05-01 16:34:50 +02:00
2017-08-03 01:45:31 +02:00
if ( $action == 'confirm_createfromclone' )
{
2018-09-25 20:34:05 +02:00
$db -> begin ();
2017-08-03 01:45:31 +02:00
$objectnew = new Website ( $db );
2019-11-12 00:15:34 +01:00
$result = $objectnew -> createFromClone ( $user , GETPOST ( 'id' , 'int' ), GETPOST ( 'siteref' , 'aZ09' ), ( GETPOST ( 'newlang' , 'aZ09' ) ? GETPOST ( 'newlang' , 'aZ09' ) : '' ));
2017-08-03 01:45:31 +02:00
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $objectnew -> error , $objectnew -> errors , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'preview' ;
2018-09-25 20:34:05 +02:00
$db -> rollback ();
2017-08-21 00:40:45 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2017-08-21 00:40:45 +02:00
$object = $objectnew ;
$id = $object -> id ;
$pageid = $object -> fk_default_home ;
2019-01-27 11:55:16 +01:00
$websitekey = GETPOST ( 'siteref' , 'aZ09' );
2018-09-25 20:34:05 +02:00
$db -> commit ();
2017-08-03 01:45:31 +02:00
}
}
2017-07-22 20:01:29 +02:00
if ( $action == 'confirm_createpagefromclone' )
2017-07-21 13:38:13 +02:00
{
2019-11-12 00:15:34 +01:00
$istranslation = ( GETPOST ( 'is_a_translation' , 'aZ09' ) == 'on' ? 1 : 0 );
2020-01-11 14:44:12 +01:00
// Protection if it is a translation page
2017-07-22 20:01:29 +02:00
if ( $istranslation )
2017-07-21 13:38:13 +02:00
{
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'newlang' , 'aZ09' ) == $objectpage -> lang )
2017-07-22 20:01:29 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " LanguageMustNotBeSameThanClonedPage " ), null , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'preview' ;
2017-07-22 20:01:29 +02:00
}
2020-01-11 14:44:12 +01:00
if ( GETPOST ( 'newwebsite' , 'int' ) != $object -> id ) {
$error ++ ;
setEventMessages ( $langs -> trans ( " WebsiteMustBeSameThanClonedPageIfTranslation " ), null , 'errors' );
$action = 'preview' ;
}
2017-07-21 13:38:13 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-07-22 20:01:29 +02:00
{
2018-09-25 20:34:05 +02:00
$db -> begin ();
2019-01-27 11:55:16 +01:00
$newwebsiteid = GETPOST ( 'newwebsite' , 'int' );
2018-09-25 20:34:05 +02:00
$pathofwebsitenew = $pathofwebsite ;
2019-11-12 00:15:34 +01:00
$tmpwebsite = new Website ( $db );
2018-09-25 20:34:05 +02:00
if ( $newwebsiteid > 0 && $newwebsiteid != $object -> id )
{
$tmpwebsite -> fetch ( $newwebsiteid );
$pathofwebsitenew = $dolibarr_main_data_root . '/website/' . $tmpwebsite -> ref ;
}
2020-05-21 09:07:10 +02:00
else {
2018-09-25 20:34:05 +02:00
$tmpwebsite = $object ;
}
2017-10-07 13:09:31 +02:00
$objectpage = new WebsitePage ( $db );
2020-01-11 14:44:12 +01:00
$resultpage = $objectpage -> createFromClone ( $user , $pageid , GETPOST ( 'newpageurl' , 'aZ09' ), ( GETPOST ( 'newlang' , 'aZ09' ) ? GETPOST ( 'newlang' , 'aZ09' ) : '' ), $istranslation , $newwebsiteid , GETPOST ( 'newtitle' , 'alphanohtml' ));
2018-09-25 20:34:05 +02:00
if ( $resultpage < 0 )
2017-07-22 20:01:29 +02:00
{
$error ++ ;
setEventMessages ( $objectpage -> error , $objectpage -> errors , 'errors' );
2019-11-12 00:15:34 +01:00
$action = 'createpagefromclone' ;
2018-09-25 20:34:05 +02:00
$db -> rollback ();
2020-05-23 18:34:58 +02:00
} else {
2019-11-12 00:15:34 +01:00
$filetpl = $pathofwebsitenew . '/page' . $resultpage -> id . '.tpl.php' ;
2020-05-23 13:10:33 +02:00
$fileindex = $pathofwebsitenew . '/index.php' ;
2019-11-12 00:15:34 +01:00
$filewrapper = $pathofwebsitenew . '/wrapper.php' ;
2018-09-25 20:34:05 +02:00
//var_dump($pathofwebsitenew);
//var_dump($filetpl);
//exit;
dolSavePageContent ( $filetpl , $tmpwebsite , $resultpage );
// Switch on the new page if web site of new page/container is same
if ( empty ( $newwebsiteid ) || $newwebsiteid == $object -> id )
{
$pageid = $resultpage -> id ;
}
$db -> commit ();
2017-10-26 14:16:59 +02:00
}
2017-07-22 20:01:29 +02:00
}
2017-10-07 13:09:31 +02:00
}
2017-07-03 02:09:14 +02:00
2017-10-07 13:09:31 +02:00
$res = 0 ;
2017-07-22 20:01:29 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
// Check symlink to medias and restore it if ko
2019-11-12 00:15:34 +01:00
$pathtomedias = DOL_DATA_ROOT . '/medias' ;
$pathtomediasinwebsite = $pathofwebsite . '/medias' ;
if ( ! is_link ( dol_osencode ( $pathtomediasinwebsite )))
2017-10-07 13:09:31 +02:00
{
dol_syslog ( " Create symlink for " . $pathtomedias . " into name " . $pathtomediasinwebsite );
2019-11-12 00:15:34 +01:00
dol_mkdir ( dirname ( $pathtomediasinwebsite )); // To be sure dir for website exists
2017-10-07 13:09:31 +02:00
$result = symlink ( $pathtomedias , $pathtomediasinwebsite );
}
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
/* if ( GETPOST ( 'savevirtualhost' ) && $object -> virtualhost != GETPOST ( 'previewsite' ))
2017-07-22 20:01:29 +02:00
{
$object -> virtualhost = GETPOST ( 'previewsite' , 'alpha' );
$object -> update ( $user );
} */
2016-05-02 20:27:34 +02:00
2017-10-07 13:09:31 +02:00
$objectpage -> fk_website = $object -> id ;
2017-07-22 20:01:29 +02:00
2017-10-07 13:09:31 +02:00
if ( $pageid > 0 )
{
$res = $objectpage -> fetch ( $pageid );
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$res = 0 ;
2017-10-07 13:09:31 +02:00
if ( $object -> fk_default_home > 0 )
{
$res = $objectpage -> fetch ( $object -> fk_default_home );
}
2019-11-12 00:15:34 +01:00
if ( ! ( $res > 0 ))
2017-10-07 13:09:31 +02:00
{
$res = $objectpage -> fetch ( 0 , $object -> id );
}
}
}
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error && $res > 0 )
2017-10-07 13:09:31 +02:00
{
if ( $action == 'updatesource' || $action == 'updatecontent' )
{
$db -> begin ();
2017-07-02 23:38:19 +02:00
2019-04-30 13:05:13 +02:00
$phpfullcodestringold = dolKeepOnlyPhpCode ( $objectpage -> content );
2019-01-27 11:55:16 +01:00
$objectpage -> content = GETPOST ( 'PAGE_CONTENT' , 'none' );
2017-07-02 23:38:19 +02:00
2019-04-25 23:21:25 +02:00
// Security analysis
$phpfullcodestring = dolKeepOnlyPhpCode ( $objectpage -> content );
//print dol_escape_htmltag($phpfullcodestring);exit;
2019-11-12 00:15:34 +01:00
$forbiddenphpcommands = array ( " exec " , " passthru " , " system " , " shell_exec " , " proc_open " );
2019-04-25 23:21:25 +02:00
if ( empty ( $conf -> global -> WEBSITE_PHP_ALLOW_WRITE )) // If option is not on, we disallow functions to write files
{
2019-11-12 00:15:34 +01:00
$forbiddenphpcommands = array_merge ( $forbiddenphpcommands , array ( " fopen " , " file_put_contents " , " fputs " , " fputscsv " , " fwrite " , " fpassthru " , " unlink " , " mkdir " , " rmdir " , " symlink " , " touch " , " umask " ));
2019-04-25 23:21:25 +02:00
}
2019-11-12 00:15:34 +01:00
foreach ( $forbiddenphpcommands as $forbiddenphpcommand )
2019-04-25 23:21:25 +02:00
{
if ( preg_match ( '/' . $forbiddenphpcommand . '\s*\(/ms' , $phpfullcodestring ))
{
$error ++ ;
setEventMessages ( $langs -> trans ( " DynamicPHPCodeContainsAForbiddenInstruction " , $forbiddenphpcommand ), null , 'errors' );
if ( $action == 'updatesource' ) $action = 'editsource' ;
if ( $action == 'updatecontent' ) $action = 'editcontent' ;
}
}
2019-04-30 13:05:13 +02:00
if ( empty ( $user -> rights -> website -> writephp ))
{
if ( $phpfullcodestringold != $phpfullcodestring )
{
$error ++ ;
setEventMessages ( $langs -> trans ( " NotAllowedToAddDynamicContent " ), null , 'errors' );
if ( $action == 'updatesource' ) $action = 'editsource' ;
if ( $action == 'updatecontent' ) $action = 'editcontent' ;
}
}
2019-04-25 23:21:25 +02:00
2017-10-07 13:09:31 +02:00
// Clean data. We remove all the head section.
2018-09-25 15:00:37 +02:00
$objectpage -> content = preg_replace ( '/<head>.*<\/head>/ims' , '' , $objectpage -> content );
2017-10-07 13:09:31 +02:00
/* $objectpage->content = preg_replace('/<base\s+href=[\'"][^\'"]+[\'"]\s/?>/s', '', $objectpage->content); */
2017-08-21 03:13:44 +02:00
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
$res = $objectpage -> update ( $user );
if ( $res < 0 )
{
$error ++ ;
setEventMessages ( $objectpage -> error , $objectpage -> errors , 'errors' );
2019-04-25 23:21:25 +02:00
if ( $action == 'updatesource' ) $action = 'editsource' ;
if ( $action == 'updatecontent' ) $action = 'editcontent' ;
2017-10-07 13:09:31 +02:00
}
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2017-10-07 13:09:31 +02:00
{
$db -> commit ();
2019-11-12 00:15:34 +01:00
$filemaster = $pathofwebsite . '/master.inc.php' ;
2017-10-07 13:09:31 +02:00
//$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
2019-11-12 00:15:34 +01:00
$filealias = $pathofwebsite . '/' . $objectpage -> pageurl . '.php' ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
dol_mkdir ( $pathofwebsite );
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
// Now generate the master.inc.php page
2018-09-10 23:20:31 +02:00
$result = dolSaveMasterFile ( $filemaster );
2017-07-02 23:38:19 +02:00
2020-04-11 16:34:59 +02:00
if ( ! $result ) setEventMessages ( 'Failed to write the master file file ' . $filemaster , null , 'errors' );
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
// Now generate the alias.php page
2019-11-12 00:15:34 +01:00
if ( ! empty ( $fileoldalias ))
2017-10-07 13:09:31 +02:00
{
dol_syslog ( " We regenerate alias page new name= " . $filealias . " , old name= " . $fileoldalias );
dol_delete_file ( $fileoldalias );
}
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
// Save page alias
2019-11-12 00:15:34 +01:00
$result = dolSavePageAlias ( $filealias , $object , $objectpage );
2020-04-11 16:34:59 +02:00
if ( ! $result ) setEventMessages ( 'Failed to write the alias file ' . basename ( $filealias ), null , 'errors' );
2017-07-02 23:38:19 +02:00
2017-07-28 15:32:15 +02:00
// Save page content
2019-11-12 00:15:34 +01:00
$result = dolSavePageContent ( $filetpl , $object , $objectpage );
2017-10-07 13:09:31 +02:00
if ( $result )
{
setEventMessages ( $langs -> trans ( " Saved " ), null , 'mesgs' );
2019-12-08 15:57:51 +01:00
if ( ! GETPOSTISSET ( 'updateandstay' )) // If we click on "Save And Stay", we do not make the redirect
{
if ( $backtopage ) {
header ( " Location: " . $backtopage );
exit ;
} else {
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $websitekey . '&pageid=' . $pageid );
exit ;
}
2020-05-21 15:11:06 +02:00
} else {
2019-12-08 15:57:51 +01:00
if ( $action == 'updatesource' ) $action = 'editsource' ;
if ( $action == 'updatecontent' ) $action = 'editcontent' ;
}
2020-05-21 15:11:06 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( 'Failed to write file ' . $filetpl , null , 'errors' );
2018-07-22 17:18:35 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $websitekey . '&pageid=' . $pageid );
2017-10-07 13:09:31 +02:00
exit ;
}
2020-05-21 15:11:06 +02:00
} else {
2017-10-07 13:09:31 +02:00
$db -> rollback ();
}
2020-05-21 15:11:06 +02:00
} else {
2018-07-22 17:18:35 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $websitekey . '&pageid=' . $pageid );
2017-10-07 13:09:31 +02:00
exit ;
}
2020-05-21 15:11:06 +02:00
} else {
2019-11-12 00:15:34 +01:00
if ( ! $error )
2018-08-16 21:48:16 +02:00
{
2018-12-17 17:29:04 +01:00
if ( empty ( $websitekey ) || $websitekey == '-1' )
{
setEventMessages ( $langs -> trans ( " NoWebSiteCreateOneFirst " ), null , 'warnings' );
2020-05-21 15:11:06 +02:00
} else {
2018-12-17 17:29:04 +01:00
setEventMessages ( $langs -> trans ( " NoPageYet " ), null , 'warnings' );
setEventMessages ( $langs -> trans ( " YouCanCreatePageOrImportTemplate " ), null , 'warnings' );
}
2018-08-16 21:48:16 +02:00
}
2017-10-07 13:09:31 +02:00
}
2016-04-23 21:34:10 +02:00
}
2016-01-24 21:35:41 +01:00
2017-09-01 11:10:03 +02:00
// Export site
2018-08-15 14:24:33 +02:00
if ( $action == 'exportsite' )
2017-09-01 11:10:03 +02:00
{
2017-11-05 03:39:27 +01:00
$fileofzip = $object -> exportWebSite ();
2017-09-01 11:10:03 +02:00
2017-12-11 18:25:23 +01:00
if ( $fileofzip )
{
$file_name = basename ( $fileofzip );
2017-09-01 11:10:03 +02:00
2017-12-11 18:25:23 +01:00
header ( " Content-Type: application/zip " );
header ( " Content-Disposition: attachment; filename= " . $file_name );
2019-11-12 00:15:34 +01:00
header ( " Content-Length: " . filesize ( $fileofzip ));
2017-09-01 11:10:03 +02:00
2017-12-11 18:25:23 +01:00
readfile ( $fileofzip );
exit ;
}
2020-05-21 09:07:10 +02:00
else {
2019-08-14 01:43:06 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-20 13:19:32 +02:00
$action = 'preview' ;
}
}
// Regenerate site
if ( $action == 'regeneratesite' )
{
$result = $object -> rebuildWebSiteFiles ();
if ( $result > 0 )
{
setEventMessages ( $langs -> trans ( " PagesRegenerated " ), null , 'mesgs' );
$action = 'preview' ;
2020-05-21 15:11:06 +02:00
} else {
2020-05-20 13:19:32 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'preview' ;
2019-08-14 01:43:06 +02:00
}
2017-09-01 11:10:03 +02:00
}
2018-08-15 14:24:33 +02:00
// Import site
if ( $action == 'importsiteconfirm' )
{
2019-11-12 00:15:34 +01:00
if ( empty ( $_FILES ) && ! GETPOSTISSET ( 'templateuserfile' ))
2018-08-16 00:03:19 +02:00
{
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " File " )), null , 'errors' );
$action = 'importsite' ;
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
if ( ! empty ( $_FILES ) || GETPOSTISSET ( 'templateuserfile' ))
2018-08-16 21:48:16 +02:00
{
2018-09-10 21:25:30 +02:00
// Check symlink to medias and restore it if ko
2019-11-12 00:15:34 +01:00
$pathtomedias = DOL_DATA_ROOT . '/medias' ;
$pathtomediasinwebsite = $pathofwebsite . '/medias' ;
if ( ! is_link ( dol_osencode ( $pathtomediasinwebsite )))
2018-09-10 21:25:30 +02:00
{
dol_syslog ( " Create symlink for " . $pathtomedias . " into name " . $pathtomediasinwebsite );
2019-11-12 00:15:34 +01:00
dol_mkdir ( dirname ( $pathtomediasinwebsite )); // To be sure dir for website exists
2018-09-10 21:25:30 +02:00
$result = symlink ( $pathtomedias , $pathtomediasinwebsite );
2019-11-12 00:15:34 +01:00
if ( ! $result )
2018-09-10 21:25:30 +02:00
{
setEventMessages ( $langs -> trans ( " ErrorFieldToCreateSymLinkToMedias " , $pathtomediasinwebsite , $pathtomedias ), null , 'errors' );
$action = 'importsite' ;
}
}
2019-08-12 22:19:24 +02:00
$fileofzip = '' ;
if ( GETPOSTISSET ( 'templateuserfile' ))
{
$fileofzip = DOL_DATA_ROOT . '/doctemplates/websites/' . GETPOST ( 'templateuserfile' , 'alpha' );
}
2019-11-12 00:15:34 +01:00
elseif ( ! empty ( $_FILES ))
2018-08-16 21:48:16 +02:00
{
2019-11-12 00:15:34 +01:00
if ( is_array ( $_FILES [ 'userfile' ][ 'tmp_name' ])) $userfiles = $_FILES [ 'userfile' ][ 'tmp_name' ];
else $userfiles = array ( $_FILES [ 'userfile' ][ 'tmp_name' ]);
2019-08-12 22:19:24 +02:00
2019-11-12 00:15:34 +01:00
foreach ( $userfiles as $key => $userfile )
2018-08-16 21:48:16 +02:00
{
2019-08-12 22:19:24 +02:00
if ( empty ( $_FILES [ 'userfile' ][ 'tmp_name' ][ $key ]))
{
$error ++ ;
2019-11-12 00:15:34 +01:00
if ( $_FILES [ 'userfile' ][ 'error' ][ $key ] == 1 || $_FILES [ 'userfile' ][ 'error' ][ $key ] == 2 ) {
2019-08-12 22:19:24 +02:00
setEventMessages ( $langs -> trans ( 'ErrorFileSizeTooLarge' ), null , 'errors' );
$action = 'importsite' ;
}
else {
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " File " )), null , 'errors' );
$action = 'importsite' ;
}
2018-08-16 21:48:16 +02:00
}
}
2018-08-15 14:24:33 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-08-12 22:19:24 +02:00
{
$upload_dir = $conf -> website -> dir_temp ;
$result = dol_add_file_process ( $upload_dir , 1 , - 1 , 'userfile' , '' );
}
2018-08-16 21:48:16 +02:00
// Get name of file (take last one if several name provided)
$fileofzip = $upload_dir . '/unknown' ;
2019-11-12 00:15:34 +01:00
foreach ( $_FILES as $key => $ifile )
2018-08-16 21:48:16 +02:00
{
2019-11-12 00:15:34 +01:00
foreach ( $ifile [ 'name' ] as $key2 => $ifile2 )
2018-08-16 21:48:16 +02:00
{
2019-11-12 00:15:34 +01:00
$fileofzip = $upload_dir . '/' . $ifile2 ;
2018-08-16 21:48:16 +02:00
}
}
2019-08-12 22:19:24 +02:00
}
2018-08-16 21:48:16 +02:00
2019-11-12 00:15:34 +01:00
if ( ! $error )
2019-08-12 22:19:24 +02:00
{
2018-08-16 21:48:16 +02:00
$result = $object -> importWebSite ( $fileofzip );
if ( $result < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'importsite' ;
}
2020-05-21 09:07:10 +02:00
else {
2019-10-09 15:01:19 +02:00
// Force mode dynamic on
dolibarr_set_const ( $db , 'WEBSITE_SUBCONTAINERSINLINE' , 1 , 'chaine' , 0 , '' , $conf -> entity );
2018-08-16 21:48:16 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref );
exit ();
}
}
2018-08-16 00:03:19 +02:00
}
}
2018-08-15 14:24:33 +02:00
}
2016-01-24 21:35:41 +01:00
2016-02-02 16:24:12 +01:00
/*
* View
*/
$form = new Form ( $db );
2017-07-22 20:01:29 +02:00
$formadmin = new FormAdmin ( $db );
2017-07-23 16:20:53 +02:00
$formwebsite = new FormWebsite ( $db );
2018-02-19 19:47:42 +01:00
$formother = new FormOther ( $db );
2016-02-02 16:24:12 +01:00
2019-11-12 00:15:34 +01:00
$help_url = '' ;
2016-02-02 16:24:12 +01:00
2017-10-13 13:22:24 +02:00
$arrayofjs = array (
2019-09-28 13:50:32 +02:00
'/includes/ace/src/ace.js' ,
'/includes/ace/src/ext-statusbar.js' ,
'/includes/ace/src/ext-language_tools.js' ,
//'/includes/ace/src/ext-chromevox.js'
2017-12-17 16:24:47 +01:00
//'/includes/jquery/plugins/jqueryscoped/jquery.scoped.js',
2017-10-13 13:22:24 +02:00
);
$arrayofcss = array ();
2019-11-12 00:15:34 +01:00
$moreheadcss = '' ;
$moreheadjs = '' ;
2017-11-05 02:04:05 +01:00
2019-11-12 00:15:34 +01:00
$arrayofjs [] = 'includes/jquery/plugins/blockUI/jquery.blockUI.js' ;
$arrayofjs [] = 'core/js/blockUI.js' ; // Used by ecm/tpl/enabledfiletreeajax.tpl.php
if ( empty ( $conf -> global -> MAIN_ECM_DISABLE_JS )) $arrayofjs [] = " includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js " ;
2017-11-05 02:04:05 +01:00
2019-11-12 00:15:34 +01:00
$moreheadjs .= '<script type="text/javascript">' . " \n " ;
$moreheadjs .= 'var indicatorBlockUI = \'' . DOL_URL_ROOT . " /theme/ " . $conf -> theme . " /img/working.gif " . '\';' . " \n " ;
$moreheadjs .= '</script>' . " \n " ;
2017-11-05 02:04:05 +01:00
2018-11-26 14:37:19 +01:00
llxHeader ( $moreheadcss . $moreheadjs , $langs -> trans ( " WebsiteSetup " ), $help_url , '' , 0 , 0 , $arrayofjs , $arrayofcss , '' , '' , '<!-- Begin div class="fiche" -->' . " \n " . '<div class="fichebutwithotherclass">' );
2016-04-12 19:17:50 +02:00
2019-08-13 00:34:42 +02:00
print " \n " ;
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" enctype="multipart/form-data">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-02 18:43:22 +02:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2019-08-13 00:34:42 +02:00
2017-09-01 12:19:55 +02:00
if ( $action == 'createsite' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="addsite">' ;
2017-09-01 12:19:55 +02:00
}
2017-12-12 01:40:34 +01:00
if ( $action == 'createcontainer' )
2016-04-23 21:34:10 +02:00
{
2017-12-12 01:40:34 +01:00
print '<input type="hidden" name="action" value="addcontainer">' ;
2016-04-23 21:34:10 +02:00
}
2016-05-01 16:34:50 +02:00
if ( $action == 'editcss' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updatecss">' ;
2016-05-01 16:34:50 +02:00
}
if ( $action == 'editmenu' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updatemenu">' ;
2016-05-01 16:34:50 +02:00
}
2016-05-02 15:51:18 +02:00
if ( $action == 'setashome' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updateashome">' ;
2016-05-02 15:51:18 +02:00
}
2016-05-01 16:34:50 +02:00
if ( $action == 'editmeta' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updatemeta">' ;
2016-05-01 16:34:50 +02:00
}
2017-07-22 20:19:10 +02:00
if ( $action == 'editsource' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updatesource">' ;
2017-07-22 20:19:10 +02:00
}
2016-04-23 21:34:10 +02:00
if ( $action == 'editcontent' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="updatecontent">' ;
2016-04-23 21:34:10 +02:00
}
if ( $action == 'edit' )
{
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="update">' ;
2016-04-23 21:34:10 +02:00
}
2018-08-15 14:24:33 +02:00
if ( $action == 'importsite' )
{
print '<input type="hidden" name="action" value="importsiteconfirm">' ;
}
2017-11-18 15:41:30 +01:00
if ( $action == 'file_manager' )
{
print '<input type="hidden" name="action" value="file_manager">' ;
}
2019-05-28 16:10:11 +02:00
if ( $action == 'replacesite' )
{
2019-08-13 00:34:42 +02:00
print '<input type="hidden" name="action" value="replacesiteconfirm">' ;
}
if ( $action == 'replacesiteconfirm' )
{
print '<input type="hidden" name="action" value="replacesiteconfirm">' ;
2019-05-28 16:10:11 +02:00
}
2016-02-02 16:24:12 +01:00
2017-11-15 19:47:07 +01:00
print '<div>' ;
2016-02-02 16:24:12 +01:00
2016-04-23 21:34:10 +02:00
// Add a margin under toolbar ?
2019-11-12 00:15:34 +01:00
$style = '' ;
2020-04-23 18:55:10 +02:00
if ( $action != 'preview' && $action != 'editcontent' && $action != 'editsource' && ! GETPOST ( 'createpagefromclone' , 'alphanohtml' )) $style = ' margin-bottom: 5px;' ;
2016-04-23 21:34:10 +02:00
2017-12-12 01:40:34 +01:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOST ( 'hide_websitemenu' ))
2017-11-10 15:29:12 +01:00
{
2020-02-21 17:53:37 +01:00
$disabled = '' ;
if ( empty ( $user -> rights -> website -> write )) $disabled = ' disabled="disabled"' ;
2019-11-09 11:30:08 +01:00
2018-12-17 17:29:04 +01:00
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">' ;
2016-04-12 19:17:50 +02:00
2017-10-07 13:09:31 +02:00
// ***** Part for web sites
2018-11-27 16:20:31 +01:00
print '<!-- Bar for website -->' ;
2019-10-02 16:18:33 +02:00
print '<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">' ;
2017-11-15 19:47:07 +01:00
print $langs -> trans ( " Website " ) . ' : ' ;
2019-10-02 16:18:33 +02:00
print '</span>' ;
2017-09-01 12:19:55 +02:00
2019-10-02 16:18:33 +02:00
print '<span class="websiteselection hideonsmartphoneimp">' ;
2019-11-09 11:30:08 +01:00
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=createsite&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " AddWebsite " )) . '"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>' ;
2019-10-02 16:18:33 +02:00
print '</span>' ;
2017-10-07 13:09:31 +02:00
2017-10-20 21:39:19 +02:00
// List of website
2019-10-02 16:18:33 +02:00
print '<span class="websiteselection">' ;
2019-11-12 00:15:34 +01:00
$out = '' ;
2020-03-17 01:31:48 +01:00
$out .= '<select name="website" class="minwidth100 maxwidth300 maxwidth150onsmartphone" id="website">' ;
2019-11-12 00:15:34 +01:00
if ( empty ( $object -> records )) $out .= '<option value="-1"> </option>' ;
2017-10-07 13:09:31 +02:00
// Loop on each sites
2019-11-12 00:15:34 +01:00
$i = 0 ;
foreach ( $object -> records as $key => $valwebsite )
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
if ( empty ( $websitekey )) $websitekey = $valwebsite -> ref ;
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
$out .= '<option value="' . $valwebsite -> ref . '"' ;
if ( $websitekey == $valwebsite -> ref ) $out .= ' selected' ; // To preselect a value
$out .= '>' ;
$out .= $valwebsite -> ref ;
$out .= '</option>' ;
2017-10-07 13:09:31 +02:00
$i ++ ;
}
2019-11-12 00:15:34 +01:00
$out .= '</select>' ;
$out .= ajax_combobox ( 'website' );
2017-10-07 13:09:31 +02:00
print $out ;
2017-11-15 19:47:07 +01:00
//print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
2019-04-05 11:34:06 +02:00
print '<input type="image" class="valignmiddle" src="' . img_picto ( '' , 'refresh' , '' , 0 , 1 ) . '" name="refreshsite" value="' . $langs -> trans ( " Load " ) . '">' ;
2017-11-15 19:47:07 +01:00
2017-10-07 13:09:31 +02:00
2018-07-22 17:18:35 +02:00
if ( $websitekey )
2017-10-07 13:09:31 +02:00
{
2020-02-21 17:53:37 +01:00
$virtualurl = '' ;
$dataroot = DOL_DATA_ROOT . '/website/' . $websitekey ;
if ( ! empty ( $object -> virtualhost )) $virtualurl = $object -> virtualhost ;
2017-10-07 13:09:31 +02:00
}
2020-02-21 17:53:37 +01:00
$array = array ();
2018-12-17 17:29:04 +01:00
if ( $object -> id > 0 )
{
2020-02-21 17:53:37 +01:00
$array = $objectpage -> fetchAll ( $object -> id , 'ASC,ASC' , 'type_container,pageurl' );
2019-10-31 21:09:33 +01:00
$object -> lines = $array ;
2018-12-17 17:29:04 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! is_array ( $array ) && $array < 0 ) dol_print_error ( '' , $objectpage -> error , $objectpage -> errors );
$atleastonepage = ( is_array ( $array ) && count ( $array ) > 0 );
2018-08-15 14:24:33 +02:00
2019-06-02 17:27:00 +02:00
if ( $websitekey && $websitekey != '-1' && ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite' ))
2017-10-07 13:09:31 +02:00
{
2017-08-20 21:23:19 +02:00
print ' ' ;
2019-08-15 18:59:08 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $langs -> trans ( " EditCss " )) . '" name="editcss">' ;
2019-05-28 16:10:11 +02:00
2020-05-17 15:06:09 +02:00
$importlabel = $langs -> trans ( " ImportSite " );
$exportlabel = $langs -> trans ( " ExportSite " );
if ( ! empty ( $conf -> dol_optimize_smallscreen )) {
$importlabel = $langs -> trans ( " Import " );
$exportlabel = $langs -> trans ( " Export " );
}
2019-10-31 21:09:33 +01:00
if ( $atleastonepage )
2018-08-15 14:24:33 +02:00
{
2020-05-17 15:06:09 +02:00
print '<input type="submit" class="button bordertransp" disabled="disabled" value="' . dol_escape_htmltag ( $importlabel ) . '" name="importsite">' ;
2018-08-15 14:24:33 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2020-05-17 15:06:09 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $importlabel ) . '" name="importsite">' ;
2018-08-15 14:24:33 +02:00
}
2017-07-02 23:38:19 +02:00
2019-05-28 16:10:11 +02:00
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
2020-05-17 15:06:09 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $exportlabel ) . '" name="exportsite">' ;
2019-08-18 18:36:18 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $langs -> trans ( " CloneSite " )) . '" name="createfromclone">' ;
2019-05-28 16:10:11 +02:00
2019-11-12 00:15:34 +01:00
print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="' . $langs -> trans ( " Delete " ) . '"' . ( $atleastonepage ? ' disabled="disabled"' : '' ) . '>' ;
2018-09-08 12:04:40 +02:00
2017-10-07 13:09:31 +02:00
print ' ' ;
2016-04-27 09:41:42 +02:00
2019-08-15 18:59:08 +02:00
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=file_manager&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " MediaFiles " )) . '"><span class="fa fa-image"><span></a>' ;
//print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="file_manager">';
2017-11-10 15:29:12 +01:00
/* print '<a class="button button_file_manager"' . $disabled . '>' . dol_escape_htmltag ( $langs -> trans ( " MediaFiles " )) . '</a>' ;
print ' < script language = " javascript " >
jQuery ( document ) . ready ( function () {
jQuery ( " .button_file_manager " ) . click ( function () {
2018-07-22 17:18:35 +02:00
var $dialog = $ ( \ '<div></div>\').html(\'<iframe style="border: 0px;" src="' . DOL_URL_ROOT . '/website/index.php?hide_websitemenu=1&dol_hide_topmenu=1&dol_hide_leftmenu=1&file_manager=1&website=' . $websitekey . '&pageid=' . $pageid . ' " width= " 100 % " height= " 100 % " ></iframe> \ ')
2017-11-10 15:29:12 +01:00
. dialog ({
autoOpen : false ,
modal : true ,
height : 500 ,
width : \ ' 80 % \ ' ,
title : " '.dol_escape_js( $langs->trans ( " FileManager " )).' "
});
$dialog . dialog ( \ ' open\ ' );
});
});
</ script > ' ;
*/
2019-05-28 16:10:11 +02:00
2019-09-02 16:13:11 +02:00
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=replacesite&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " ReplaceWebsiteContent " )) . '"><span class="fa fa-search"><span></a>' ;
2020-05-23 15:50:15 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
print '<a href="' . DOL_URL_ROOT . '/categories/index.php?leftmenu=website&type=website_page&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " Categories " )) . '"><span class="fa fa-tags"><span></a>' ;
}
2020-05-20 13:19:32 +02:00
if ( ! empty ( $conf -> global -> WEBSITE_ADD_REGENERATE_BUTTON )) {
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=regeneratesite&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " RegenerateWebsiteContent " )) . '"><span class="fa fa-cogs"><span></a>' ;
}
2017-10-07 13:09:31 +02:00
}
2019-10-02 16:18:33 +02:00
print '</span>' ;
2016-04-27 09:41:42 +02:00
2018-08-15 14:24:33 +02:00
2018-09-25 15:00:37 +02:00
// Toolbar for websites
2019-10-02 16:18:33 +02:00
print '<span class="websitetools websiteselection">' ;
2017-10-07 02:29:27 +02:00
2019-06-02 17:27:00 +02:00
if ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite' )
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$urlext = $virtualurl ;
$urlint = $urlwithroot . '/public/website/index.php?website=' . $websitekey ;
2018-02-19 21:31:03 +01:00
2019-10-02 16:18:33 +02:00
print '<span class="websiteinputurl valignmiddle" id="websiteinputurl">' ;
2019-11-12 00:15:34 +01:00
$linktotestonwebserver = '<a href="' . ( $virtualurl ? $virtualurl : '#' ) . '" class="valignmiddle">' ;
2020-05-17 15:06:09 +02:00
$linktotestonwebserver .= '<span class="hideonsmartphone">' . $langs -> trans ( " TestDeployOnWeb " , $virtualurl ) . ' </span>' . img_picto ( '' , 'globe' );
2019-11-12 00:15:34 +01:00
$linktotestonwebserver .= '</a>' ;
2019-01-23 14:57:43 +01:00
$htmltext = '' ;
2018-02-15 01:29:51 +01:00
if ( empty ( $object -> fk_default_home ))
{
2019-11-12 00:15:34 +01:00
$htmltext .= '<br><span class="error">' . $langs -> trans ( " YouMustDefineTheHomePage " ) . '</span><br><br>' ;
2019-01-23 14:57:43 +01:00
}
2019-01-23 15:06:28 +01:00
elseif ( empty ( $virtualurl ))
2019-01-23 14:57:43 +01:00
{
2019-12-02 09:19:05 +01:00
//$htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>';
2018-02-15 01:29:51 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$htmltext .= '<br><center>' . $langs -> trans ( " GoTo " ) . ' <a href="' . $virtualurl . '" target="_website">' . $virtualurl . '</a></center><br>' ;
2018-02-15 01:29:51 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! empty ( $conf -> global -> WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER ))
2019-01-23 14:57:43 +01:00
{
2019-11-12 00:15:34 +01:00
$htmltext .= '<br>' . $langs -> trans ( $conf -> global -> WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER );
2019-01-23 14:57:43 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-11-12 00:15:34 +01:00
$htmltext .= $langs -> trans ( " SetHereVirtualHost " , $dataroot );
$htmltext .= '<br>' ;
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " ReadPerm " ), DOL_DOCUMENT_ROOT );
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " WritePerm " ), DOL_DATA_ROOT . '/website<br>' . DOL_DATA_ROOT . '/medias' );
2020-03-11 12:53:41 +01:00
2020-04-13 23:21:28 +02:00
$examplewithapache = '#php_admin_value open_basedir /tmp/:' . DOL_DOCUMENT_ROOT . ':' . DOL_DATA_ROOT . ':/dev/urandom' . " \n " ;
$examplewithapache .= '<Directory "' . DOL_DOCUMENT_ROOT . '">' . " \n " ;
2020-03-11 12:53:41 +01:00
$examplewithapache .= ' AllowOverride FileInfo Options
Options - Indexes - MultiViews - FollowSymLinks - ExecCGI
Require all granted
</ Directory >
< Directory " '.DOL_DATA_ROOT.'/website " >
AllowOverride FileInfo Options
Options - Indexes - MultiViews + FollowSymLinks - ExecCGI
Require all granted
</ Directory >
< Directory " '.DOL_DATA_ROOT.'/medias " >
AllowOverride FileInfo Options
Options - Indexes - MultiViews - FollowSymLinks - ExecCGI
Require all granted
</ Directory > ' ;
$htmltext .= '<br>' . $langs -> trans ( " ExampleToUseInApacheVirtualHostConfig " ) . ':<br>' ;
$htmltext .= '<div class="centpercent exampleapachesetup">' . dol_nl2br ( dol_escape_htmltag ( $examplewithapache , 1 , 1 )) . '</div>' ;
2019-11-12 00:15:34 +01:00
$htmltext .= '<br>' ;
$htmltext .= $langs -> trans ( " YouCanAlsoTestWithPHPS " , $dataroot );
$htmltext .= '<br>' ;
$htmltext .= '<br>' ;
$htmltext .= $langs -> trans ( " YouCanAlsoDeployToAnotherWHP " );
2019-01-23 14:57:43 +01:00
}
2019-10-02 16:18:33 +02:00
print $form -> textwithpicto ( $linktotestonwebserver , $htmltext , 1 , 'none' , 'valignmiddle' , 0 , 3 , 'helpvirtualhost' );
print '</span>' ;
2017-10-07 13:09:31 +02:00
}
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
if ( in_array ( $action , array ( 'editcss' , 'editmenu' , 'file_manager' , 'replacesite' , 'replacesiteconfirm' )))
2017-10-07 13:09:31 +02:00
{
2019-12-08 15:57:51 +01:00
if ( $action == 'editcss' ) print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " SaveAndStay " )) . '" name="updateandstay">' ;
2019-08-13 00:34:42 +02:00
if ( preg_match ( '/^create/' , $action ) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm' ) print '<input type="submit" id="savefile" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '" name="update">' ;
if ( preg_match ( '/^edit/' , $action ) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm' ) print '<input type="submit" id="savefile" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '" name="update">' ;
2019-09-02 18:43:22 +02:00
if ( $action != 'preview' ) print '<input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '" name="cancel">' ;
2017-10-07 13:09:31 +02:00
}
2016-04-27 09:41:42 +02:00
2019-10-02 16:18:33 +02:00
print '</span>' ;
2017-07-02 23:38:19 +02:00
2016-04-27 09:41:42 +02:00
2018-08-15 14:24:33 +02:00
// Toolbar for pages
2016-04-27 09:41:42 +02:00
2019-11-12 00:15:34 +01:00
if ( $websitekey && $websitekey != '-1' && ! in_array ( $action , array ( 'editcss' , 'editmenu' , 'importsite' )))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
print '</div>' ; // Close current websitebar to open a new one
2017-07-02 23:38:19 +02:00
2018-11-27 16:20:31 +01:00
print '<!-- Bar for websitepage -->' ;
2019-11-12 00:15:34 +01:00
print '<div class="centpercent websitebar"' . ( $style ? ' style="' . $style . '"' : '' ) . '">' ;
2017-07-02 23:38:19 +02:00
2019-10-02 16:18:33 +02:00
print '<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">' ;
2017-11-15 19:47:07 +01:00
print $langs -> trans ( " PageContainer " ) . ': ' ;
2019-10-02 16:18:33 +02:00
print '</span>' ;
2017-07-21 13:38:13 +02:00
2019-10-02 16:18:33 +02:00
print '<span class="websiteselection hideonsmartphoneimp">' ;
2019-11-09 11:30:08 +01:00
//print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'" name="createcontainer">';
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=createcontainer&website=' . $website -> ref . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " AddPage " )) . '"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>' ;
2019-10-02 16:18:33 +02:00
print '</span>' ;
2017-11-15 19:47:07 +01:00
2019-10-31 21:09:33 +01:00
//print '<span class="websiteselection">';
2017-07-21 13:38:13 +02:00
2017-12-12 01:40:34 +01:00
if ( $action != 'addcontainer' )
2017-10-07 13:09:31 +02:00
{
2020-03-17 01:31:48 +01:00
print '<span class="websiteselection">' . $formwebsite -> selectContainer ( $website , 'pageid' , $pageid , 0 , $action , 'maxwidth200onsmartphone' ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2017-10-07 13:09:31 +02:00
print $langs -> trans ( " New " );
}
2017-07-02 23:38:19 +02:00
2017-11-15 19:47:07 +01:00
//print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
2019-11-12 00:15:34 +01:00
print '<input type="image" class="valignmiddle" src="' . img_picto ( '' , 'refresh' , '' , 0 , 1 ) . '" name="refreshpage" value="' . $langs -> trans ( " Load " ) . '"' . (( $atleastonepage && $action != 'editsource' ) ? '' : ' disabled="disabled"' ) . '>' ;
2016-08-08 14:21:43 +02:00
2018-05-25 17:47:03 +02:00
// Print nav arrows
2019-11-12 00:15:34 +01:00
$pagepreviousid = 0 ;
$pagenextid = 0 ;
2018-06-11 09:22:50 +02:00
if ( $pageid )
2018-05-25 17:47:03 +02:00
{
2018-06-11 09:22:50 +02:00
$sql = 'SELECT MAX(rowid) as pagepreviousid FROM ' . MAIN_DB_PREFIX . 'website_page WHERE rowid < ' . $pageid . ' AND fk_website = ' . $object -> id ;
$resql = $db -> query ( $sql );
if ( $resql )
2018-05-25 17:47:03 +02:00
{
2018-06-11 09:22:50 +02:00
$obj = $db -> fetch_object ( $resql );
if ( $obj )
{
$pagepreviousid = $obj -> pagepreviousid ;
}
2018-05-25 17:47:03 +02:00
}
2018-06-11 09:22:50 +02:00
else dol_print_error ( $db );
$sql = 'SELECT MIN(rowid) as pagenextid FROM ' . MAIN_DB_PREFIX . 'website_page WHERE rowid > ' . $pageid . ' AND fk_website = ' . $object -> id ;
$resql = $db -> query ( $sql );
if ( $resql )
2018-05-25 17:47:03 +02:00
{
2018-06-11 09:22:50 +02:00
$obj = $db -> fetch_object ( $resql );
if ( $obj )
{
$pagenextid = $obj -> pagenextid ;
}
2018-05-25 17:47:03 +02:00
}
2018-06-11 09:22:50 +02:00
else dol_print_error ( $db );
2018-05-25 17:47:03 +02:00
}
2018-05-25 17:59:58 +02:00
2018-07-23 14:08:20 +02:00
if ( $pagepreviousid ) print '<a class="valignmiddle" href="' . $_SERVER [ 'PHP_SELF' ] . '?website=' . urlencode ( $object -> ref ) . '&pageid=' . $pagepreviousid . '&action=' . $action . '">' . img_previous ( $langs -> trans ( " PreviousContainer " )) . '</a>' ;
else print '<span class="valignmiddle opacitymedium">' . img_previous ( $langs -> trans ( " PreviousContainer " )) . '</span>' ;
if ( $pagenextid ) print '<a class="valignmiddle" href="' . $_SERVER [ 'PHP_SELF' ] . '?website=' . urlencode ( $object -> ref ) . '&pageid=' . $pagenextid . '&action=' . $action . '">' . img_next ( $langs -> trans ( " NextContainer " )) . '</a>' ;
else print '<span class="valignmiddle opacitymedium">' . img_next ( $langs -> trans ( " NextContainer " )) . '</span>' ;
2018-05-25 17:47:03 +02:00
2018-02-14 20:33:48 +01:00
$websitepage = new WebSitePage ( $db );
if ( $pageid > 0 && ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' ))
{
$websitepage -> fetch ( $pageid );
}
2019-06-02 17:27:00 +02:00
if ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite' )
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$disabled = '' ;
if ( empty ( $user -> rights -> website -> write )) $disabled = ' disabled="disabled"' ;
2017-10-07 13:09:31 +02:00
2019-06-02 17:27:00 +02:00
// Confirmation delete site
if ( $action == 'deletesite' ) {
// Create an array for form
$formquestion = array (
array ( 'type' => 'checkbox' , 'name' => 'delete_also_js' , 'label' => $langs -> trans ( " DeleteAlsoJs " ), 'value' => 0 ),
array ( 'type' => 'checkbox' , 'name' => 'delete_also_medias' , 'label' => $langs -> trans ( " DeleteAlsoMedias " ), 'value' => 0 ),
2019-09-24 14:20:45 +02:00
//array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')),
2019-06-02 17:27:00 +02:00
//array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0))
);
2019-11-12 00:15:34 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'DeleteWebsite' ), '' , 'confirm_deletesite' , $formquestion , 0 , 1 , 200 );
2019-06-02 17:27:00 +02:00
print $formconfirm ;
}
2017-10-07 13:09:31 +02:00
// Confirmation to clone
if ( $action == 'createfromclone' ) {
// Create an array for form
$formquestion = array (
2020-01-11 14:44:12 +01:00
array ( 'type' => 'text' , 'name' => 'siteref' , 'label' => $langs -> trans ( " WebSite " ), 'value' => 'copy_of_' . $object -> ref )
2017-10-07 13:09:31 +02:00
);
2019-11-12 00:15:34 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'CloneSite' ), '' , 'confirm_createfromclone' , $formquestion , 0 , 1 , 200 );
2017-10-07 13:09:31 +02:00
print $formconfirm ;
}
2017-07-02 23:38:19 +02:00
2019-06-02 17:27:00 +02:00
if ( $pageid > 0 && $atleastonepage ) // pageid can be set without pages, if homepage of site is set and all pages were removed
2017-10-07 13:09:31 +02:00
{
// Confirmation to clone
if ( $action == 'createpagefromclone' ) {
// Create an array for form
2019-09-24 14:20:45 +02:00
$preselectedlanguage = GETPOST ( 'newlang' , 'aZ09' ) ? GETPOST ( 'newlang' , 'aZ09' ) : ( $objectpage -> lang ? $objectpage -> lang : $langs -> defaultlang );
2020-04-16 14:31:30 +02:00
$onlylang = array ();
if ( $website -> otherlang ) {
2020-04-23 18:55:10 +02:00
foreach ( explode ( ',' , $website -> otherlang ) as $langkey ) {
2020-04-16 14:31:30 +02:00
$onlylang [ $langkey ] = $langkey ;
}
$textifempty = 1 ;
} else {
$onlylang [ 'none' ] = '' ;
}
$textifempty = 1 ;
2017-07-22 20:01:29 +02:00
$formquestion = array (
2018-10-14 18:44:29 +02:00
array ( 'type' => 'hidden' , 'name' => 'sourcepageurl' , 'value' => $objectpage -> pageurl ),
2018-08-24 15:16:03 +02:00
array ( 'type' => 'checkbox' , 'tdclass' => 'maxwidth200' , 'name' => 'is_a_translation' , 'label' => $langs -> trans ( " PageIsANewTranslation " ), 'value' => 0 ),
2020-04-16 14:31:30 +02:00
array ( 'type' => 'other' , 'name' => 'newlang' , 'label' => $form -> textwithpicto ( $langs -> trans ( " Language " ), $langs -> trans ( " DefineListOfAltLanguagesInWebsiteProperties " )), 'value' => $formadmin -> select_language ( $preselectedlanguage , 'newlang' , 0 , null , $textifempty , 0 , 0 , 'minwidth200' , 0 , 1 , 0 , $onlylang , 1 )),
2019-11-12 00:15:34 +01:00
array ( 'type' => 'other' , 'name' => 'newwebsite' , 'label' => $langs -> trans ( " WebSite " ), 'value' => $formwebsite -> selectWebsite ( $object -> id , 'newwebsite' , 0 )),
2020-01-11 14:44:12 +01:00
array ( 'type' => 'text' , 'tdclass' => 'maxwidth200 fieldrequired' , 'name' => 'newtitle' , 'label' => $langs -> trans ( " WEBSITE_TITLE " ), 'value' => $langs -> trans ( " CopyOf " ) . ' ' . $objectpage -> title ),
array ( 'type' => 'text' , 'tdclass' => 'maxwidth200' , 'name' => 'newpageurl' , 'label' => $langs -> trans ( " WEBSITE_PAGENAME " ), 'value' => '' ),
2017-07-23 16:20:53 +02:00
);
2017-07-22 20:01:29 +02:00
2019-11-12 00:15:34 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref . '&pageid=' . $pageid , $langs -> trans ( 'ClonePage' ), '' , 'confirm_createpagefromclone' , $formquestion , 0 , 1 , 300 , 550 );
2017-07-22 20:01:29 +02:00
print $formconfirm ;
2017-10-07 13:09:31 +02:00
}
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
print ' ' ;
2016-09-14 23:23:22 +02:00
2019-08-15 18:59:08 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $langs -> trans ( " EditPageMeta " )) . '" name="editmeta">' ;
2018-07-19 21:35:21 +02:00
2019-08-15 18:59:08 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $langs -> trans ( " EditHTMLSource " )) . '" name="editsource">' ;
2018-07-19 21:35:21 +02:00
2018-10-14 14:26:18 +02:00
print '<!-- button EditInLine and ShowSubcontainers -->' . " \n " ;
2018-09-10 09:09:51 +02:00
print '<div class="websiteselectionsection inline-block">' ;
2019-10-31 21:09:33 +01:00
print '<div class="inline-block marginrightonly">' ;
2019-08-14 19:48:52 +02:00
2019-09-10 17:50:55 +02:00
print '<span id="switchckeditorinline">' . " \n " ;
print '<!-- Code to enabled edit inline ckeditor -->' . " \n " ;
2019-08-14 19:48:52 +02:00
print ' < script type = " text/javascript " >
$ ( document ) . ready ( function () {
2019-11-12 00:15:34 +01:00
var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ? ' true ' : ' false ').' ;
2019-08-14 19:48:52 +02:00
if ( isEditingEnabled )
{
switchEditorOnline ( true );
}
$ ( " #switchckeditorinline " ) . click ( function () {
switchEditorOnline ();
});
function switchEditorOnline ( forceenable )
{
if ( ! isEditingEnabled || forceenable )
{
console . log ( " Enable inline edit " );
2020-03-11 12:53:41 +01:00
jQuery ( \ ' section [ contenteditable = " true " ], div [ contenteditable = " true " ] \ ' ) . each ( function ( idx ){
2019-08-14 19:48:52 +02:00
var idtouse = $ ( this ) . attr ( \ ' id\ ' );
console . log ( " Enable inline edit for " + idtouse );
CKEDITOR . inline ( idtouse , {
// Allow some non-standard markup that we used in the introduction.
2020-03-11 13:55:57 +01:00
extraAllowedContent : \ ' span ( * ); cite ( * ); q ( * ); dl ( * ); dt ( * ); dd ( * ); ul ( * ); li ( * ); header ( * ); button ( * ); h1 ( * ); h2 ( * ); \ ' ,
2019-09-10 17:50:55 +02:00
//extraPlugins: \'sourcedialog\',
removePlugins : \ ' flash , stylescombo\ ' ,
2019-08-14 19:48:52 +02:00
// Show toolbar on startup (optional).
// startupFocus: true
});
})
isEditingEnabled = true ;
}
else {
console . log ( " Disable inline edit " );
for ( name in CKEDITOR . instances )
{
CKEDITOR . instances [ name ] . destroy ( true );
}
isEditingEnabled = false ;
}
};
});
</ script > ' ;
2018-09-28 00:59:02 +02:00
print $langs -> trans ( " EditInLine " );
2019-08-14 19:48:52 +02:00
print '</span>' ;
2020-03-11 12:53:41 +01:00
//$disableeditinline = $websitepage->grabbed_from;
$disableeditinline = 0 ;
if ( $disableeditinline )
2018-02-14 20:33:48 +01:00
{
2019-08-15 18:59:08 +02:00
//print '<input type="submit" class="button bordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
2019-10-31 21:09:33 +01:00
print '<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"' . $disabled . ' href="#" disabled="disabled" title="' . dol_escape_htmltag ( $langs -> trans ( " OnlyEditionOfSourceForGrabbedContent " )) . '">' . img_picto ( $langs -> trans ( " OnlyEditionOfSourceForGrabbedContent " ), 'switch_off' , '' , false , 0 , 0 , '' , 'nomarginleft' ) . '</a>' ;
2018-02-14 20:33:48 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2018-07-19 21:35:21 +02:00
//print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
if ( empty ( $conf -> global -> WEBSITE_EDITINLINE ))
{
2019-10-31 21:09:33 +01:00
print '<a class="nobordertransp nohoverborder marginleftonlyshort"' . $disabled . ' href="' . $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref . '&pageid=' . $websitepage -> id . '&action=seteditinline">' . img_picto ( $langs -> trans ( " EditInLineOnOff " , $langs -> transnoentitiesnoconv ( " Off " )), 'switch_off' , '' , false , 0 , 0 , '' , 'nomarginleft' ) . '</a>' ;
2018-07-19 21:35:21 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-10-31 21:09:33 +01:00
print '<a class="nobordertransp nohoverborder marginleftonlyshort"' . $disabled . ' href="' . $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref . '&pageid=' . $websitepage -> id . '&action=unseteditinline">' . img_picto ( $langs -> trans ( " EditInLineOnOff " , $langs -> transnoentitiesnoconv ( " On " )), 'switch_on' , '' , false , 0 , 0 , '' , 'nomarginleft' ) . '</a>' ;
2018-07-19 21:35:21 +02:00
}
2018-02-14 20:33:48 +01:00
}
2019-08-14 19:48:52 +02:00
2018-09-10 09:09:51 +02:00
print '</div>' ;
2019-10-31 21:09:33 +01:00
print '<div class="inline-block marginrightonly">' ;
2018-09-10 09:09:51 +02:00
print $langs -> trans ( " ShowSubcontainers " );
2019-10-26 20:53:39 +02:00
if ( empty ( $conf -> global -> WEBSITE_SUBCONTAINERSINLINE ))
{
2019-10-31 21:09:33 +01:00
print '<a class="nobordertransp nohoverborder marginleftonlyshort"' . $disabled . ' href="' . $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref . '&pageid=' . $websitepage -> id . '&action=setshowsubcontainers">' . img_picto ( $langs -> trans ( " ShowSubContainersOnOff " , $langs -> transnoentitiesnoconv ( " Off " )), 'switch_off' , '' , false , 0 , 0 , '' , 'nomarginleft' ) . '</a>' ;
2019-10-26 20:53:39 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-10-31 21:09:33 +01:00
print '<a class="nobordertransp nohoverborder marginleftonlyshort"' . $disabled . ' href="' . $_SERVER [ " PHP_SELF " ] . '?website=' . $object -> ref . '&pageid=' . $websitepage -> id . '&action=unsetshowsubcontainers">' . img_picto ( $langs -> trans ( " ShowSubContainersOnOff " , $langs -> transnoentitiesnoconv ( " On " )), 'switch_on' , '' , false , 0 , 0 , '' , 'nomarginleft' ) . '</a>' ;
2019-10-26 20:53:39 +02:00
}
2018-10-14 14:26:18 +02:00
/*}*/
2018-09-10 09:09:51 +02:00
print '</div>' ;
print '</div>' ;
2018-07-19 21:35:21 +02:00
2019-11-09 12:03:11 +01:00
// Set page as homepage
2019-06-02 17:27:00 +02:00
if ( $object -> fk_default_home > 0 && $pageid == $object -> fk_default_home )
{
//$disabled=' disabled="disabled"';
2019-08-15 18:59:08 +02:00
//print '<span class="button bordertransp disabled"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home"></span></span>';
2019-11-09 12:03:11 +01:00
//print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<a href="#" class="button bordertransp disabled" disabled="disabled" title="' . dol_escape_htmltag ( $langs -> trans ( " SetAsHomePage " )) . '"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>' ;
2019-06-02 17:27:00 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-06-02 17:27:00 +02:00
//$disabled='';
2019-11-09 12:03:11 +01:00
//print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<a href="' . $_SERVER [ " PHP_SEFL " ] . '?action=setashome&website=' . $website -> ref . '&pageid=' . $pageid . '" class="button bordertransp"' . $disabled . ' title="' . dol_escape_htmltag ( $langs -> trans ( " SetAsHomePage " )) . '"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>' ;
2019-06-02 17:27:00 +02:00
}
2019-08-15 18:59:08 +02:00
print '<input type="submit" class="button bordertransp"' . $disabled . ' value="' . dol_escape_htmltag ( $langs -> trans ( " ClonePage " )) . '" name="createpagefromclone">' ;
2019-11-12 00:15:34 +01:00
print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="' . $langs -> trans ( " Delete " ) . '"' . ( $atleastonepage ? '' : ' disabled="disabled"' ) . '>' ;
2017-10-07 13:09:31 +02:00
}
}
2016-09-14 23:23:22 +02:00
2019-10-31 21:09:33 +01:00
//print '</span>'; // end website selection
2017-07-02 23:38:19 +02:00
2019-10-02 16:18:33 +02:00
print '<span class="websitetools">' ;
2016-04-27 09:41:42 +02:00
2019-06-02 17:27:00 +02:00
if (( $pageid > 0 && $atleastonepage ) && ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite' ))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$realpage = $urlwithroot . '/public/website/index.php?website=' . $websitekey . '&pageref=' . $websitepage -> pageurl ;
2017-10-07 13:09:31 +02:00
$pagealias = $websitepage -> pageurl ;
2018-02-19 21:31:03 +01:00
$htmltext = $langs -> trans ( " PreviewSiteServedByDolibarr " , $langs -> transnoentitiesnoconv ( " Page " ), $langs -> transnoentitiesnoconv ( " Page " ), $realpage , $dataroot );
2019-11-12 00:15:34 +01:00
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " ReadPerm " ), DOL_DOCUMENT_ROOT );
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " WritePerm " ), DOL_DATA_ROOT . '/website<br>' . DOL_DATA_ROOT . '/medias' );
2018-02-19 21:31:03 +01:00
2020-03-02 17:35:49 +01:00
print '<div class="websiteinputurl inline-block paddingright">' ;
print '<a class="websitebuttonsitepreview inline-block" id="previewpage" href="' . $realpage . '&nocache=' . dol_now () . '" class="button" target="tab' . $websitekey . '" alt="' . dol_escape_htmltag ( $htmltext ) . '">' ;
2018-02-19 21:31:03 +01:00
print $form -> textwithpicto ( '' , $htmltext , 1 , 'preview' );
2019-11-12 00:15:34 +01:00
print '</a>' ; // View page in new Tab
2020-03-02 17:35:49 +01:00
print '</div>' ;
2017-10-07 13:09:31 +02:00
2020-03-02 17:35:49 +01:00
/* print '<div class="websiteinputurl inline-block" id="websiteinputpage">' ;
2017-10-07 13:09:31 +02:00
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="' . $pagealias . '" disabled="disabled">' ;
2019-11-12 00:15:34 +01:00
$htmltext = $langs -> trans ( " PageNameAliasHelp " , $langs -> transnoentitiesnoconv ( " EditPageMeta " ));
2017-10-07 13:09:31 +02:00
print $form -> textwithpicto ( '' , $htmltext , 1 , 'help' , '' , 0 , 2 , 'helppagealias' );
2020-03-02 17:35:49 +01:00
print '</div>' ; */
2017-10-07 13:09:31 +02:00
2020-03-02 17:35:49 +01:00
/*
2019-11-12 00:15:34 +01:00
$urlext = $virtualurl . '/' . $pagealias . '.php' ;
$urlint = $urlwithroot . '/public/website/index.php?website=' . $websitekey ;
2018-02-19 21:31:03 +01:00
2019-11-12 00:15:34 +01:00
$htmltext = $langs -> trans ( " PreviewSiteServedByWebServer " , $langs -> transnoentitiesnoconv ( " Page " ), $langs -> transnoentitiesnoconv ( " Page " ), $dataroot , $virtualurl ? $urlext : '<span class="error">' . $langs -> trans ( " VirtualHostUrlNotDefined " ) . '</span>' );
2018-02-19 21:31:03 +01:00
2019-11-12 00:15:34 +01:00
print '<a class="websitebuttonsitepreview' . ( $virtualurl ? '' : ' websitebuttonsitepreviewdisabled cursornotallowed' ) . '" id="previewpageext" href="' . $urlext . '" target="tab' . $websitekey . 'ext" alt="' . dol_escape_htmltag ( $htmltext ) . '">' ;
2018-02-19 21:31:03 +01:00
print $form -> textwithpicto ( '' , $htmltext , 1 , 'preview_ext' );
2017-10-07 13:09:31 +02:00
print '</a>' ;
2020-03-02 17:35:49 +01:00
*/
2018-07-22 17:18:35 +02:00
//print '<input type="submit" class="button" name="previewpage" target="tab'.$websitekey.'"value="'.$langs->trans("ViewPageInNewTab").'">';
2017-10-07 13:09:31 +02:00
// TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext
}
2019-11-12 00:15:34 +01:00
if ( ! in_array ( $action , array ( 'editcss' , 'editmenu' , 'file_manager' , 'replacesite' , 'replacesiteconfirm' , 'createsite' , 'createcontainer' , 'createfromclone' , 'createpagefromclone' , 'deletesite' )))
2017-10-07 13:09:31 +02:00
{
2019-12-08 15:57:51 +01:00
if ( $action == 'editsource' || $action == 'editmeta' ) print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " SaveAndStay " )) . '" name="updateandstay">' ;
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/^create/' , $action )) print '<input type="submit" id="savefile" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '" name="update">' ;
if ( preg_match ( '/^edit/' , $action )) print '<input type="submit" id="savefile" class="button buttonforacesave" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '" name="update">' ;
2019-12-07 19:08:40 +01:00
if ( $action != 'preview' ) print '<input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '" name="cancel">' ;
2017-10-07 13:09:31 +02:00
}
2017-07-20 16:49:20 +02:00
2019-11-12 00:15:34 +01:00
print '</span>' ; // end websitetools
2017-07-20 16:49:20 +02:00
2019-10-02 16:18:33 +02:00
print '<span class="websitehelp">' ;
2017-10-07 13:09:31 +02:00
if ( GETPOST ( 'editsource' , 'alpha' ) || GETPOST ( 'editcontent' , 'alpha' ))
{
2019-12-05 14:17:40 +01:00
$url = 'https://wiki.dolibarr.org/index.php/Module_Website' ;
$htmltext = $langs -> transnoentitiesnoconv ( " YouCanEditHtmlSource " , $url ) . '<br>' ;
2019-03-09 18:37:07 +01:00
if ( $conf -> browser -> layout == 'phone' )
{
print $form -> textwithpicto ( '' , $htmltext , 1 , 'help' , 'inline-block' , 1 , 2 , 'tooltipsubstitution' );
}
2020-05-21 09:07:10 +02:00
else {
2019-08-15 18:46:48 +02:00
//img_help(($tooltiptrigger != '' ? 2 : 1), $alt)
print $form -> textwithpicto ( $langs -> trans ( " SyntaxHelp " ) . ' ' . img_help ( 2 , $langs -> trans ( " SyntaxHelp " )), $htmltext , 1 , 'none' , 'inline-block' , 1 , 2 , 'tooltipsubstitution' );
2019-03-09 18:37:07 +01:00
}
2017-10-07 13:09:31 +02:00
}
2019-11-12 00:15:34 +01:00
print '</span>' ; // end websitehelp
2017-07-20 16:49:20 +02:00
2017-10-07 13:09:31 +02:00
if ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' )
{
// Adding jquery code to change on the fly url of preview ext
2019-11-12 00:15:34 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ))
2017-10-07 13:09:31 +02:00
{
print ' < script type = " text/javascript " language = " javascript " >
2016-09-14 23:23:22 +02:00
jQuery ( document ) . ready ( function () {
2017-07-20 11:51:30 +02:00
jQuery ( " #websiteinputurl " ) . keyup ( function () {
console . log ( " Website external url modified " + jQuery ( " #previewsiteurl " ) . val ());
2018-06-11 10:34:54 +02:00
if ( jQuery ( " #previewsiteurl " ) . val () != " " && jQuery ( " #previewsiteurl " ) . val () . startsWith ( " http " ))
{
jQuery ( " a.websitebuttonsitepreviewdisabled img " ) . css ({ opacity : 1 });
}
2017-07-20 11:51:30 +02:00
else jQuery ( " a.websitebuttonsitepreviewdisabled img " ) . css ({ opacity : 0.2 });
2018-02-15 01:29:51 +01:00
' ;
print '
2017-07-20 11:51:30 +02:00
});
2016-09-14 23:23:22 +02:00
jQuery ( " #previewsiteext,#previewpageext " ) . click ( function () {
2018-06-11 10:34:54 +02:00
2016-09-14 23:23:22 +02:00
newurl = jQuery ( " #previewsiteurl " ) . val ();
2018-06-11 10:34:54 +02:00
if ( ! newurl . startsWith ( " http " ))
{
2019-01-23 15:06:28 +01:00
alert ( \ '' . dol_escape_js ( $langs -> trans ( " ErrorURLMustStartWithHttp " )) . ' \ ' );
2018-06-11 10:38:04 +02:00
return false ;
2018-06-11 10:34:54 +02:00
}
2016-09-14 23:23:22 +02:00
newpage = jQuery ( " #previewsiteurl " ) . val () + " / " + jQuery ( " #previewpageurl " ) . val () + " .php " ;
console . log ( " Open url " + newurl );
/* Save url */
jQuery . ajax ({
method : " POST " ,
url : " '.DOL_URL_ROOT.'/core/ajax/saveinplace.php " ,
data : {
field : \ ' editval_virtualhost\ ' ,
2017-10-20 21:39:19 +02:00
element : \ ' website\ ' ,
2016-09-14 23:23:22 +02:00
table_element : \ ' website\ ' ,
fk_element : '.$object->id.' ,
value : newurl ,
},
context : document . body
});
2017-07-02 23:38:19 +02:00
2016-09-14 23:23:22 +02:00
jQuery ( " #previewsiteext " ) . attr ( " href " , newurl );
jQuery ( " #previewpageext " ) . attr ( " href " , newpage );
});
});
</ script > ' ;
2017-10-07 13:09:31 +02:00
}
}
}
2016-02-02 16:24:12 +01:00
2019-11-12 00:15:34 +01:00
print '</div>' ; // end current websitebar
2017-11-10 15:29:12 +01:00
}
2016-02-02 16:24:12 +01:00
$head = array ();
/*
2017-12-19 16:16:31 +01:00
* Edit Site HTML header and CSS
2016-02-02 16:24:12 +01:00
*/
2016-05-01 16:34:50 +02:00
if ( $action == 'editcss' )
2016-02-02 16:24:12 +01:00
{
2017-10-07 13:09:31 +02:00
print '<div class="fiche">' ;
print '<br>' ;
2019-09-02 18:43:22 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_CSS_INLINE' ))
2017-12-19 11:40:29 +01:00
{
$csscontent = @ file_get_contents ( $filecss );
// Clean the php css file to remove php code and get only css part
$csscontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $csscontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$csscontent = GETPOST ( 'WEBSITE_CSS_INLINE' , 'none' );
2017-12-19 11:40:29 +01:00
}
2020-04-27 00:09:21 +02:00
if ( ! trim ( $csscontent )) {
$csscontent = '/* CSS content (all pages) */' . " \n body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; } \n .bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;} " ;
}
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_JS_INLINE' ))
2017-12-19 11:40:29 +01:00
{
$jscontent = @ file_get_contents ( $filejs );
// Clean the php js file to remove php code and get only js part
$jscontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $jscontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$jscontent = GETPOST ( 'WEBSITE_JS_INLINE' , 'none' );
2017-12-19 11:40:29 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $jscontent )) $jscontent = '/* JS content (all pages) */' . " \n " ;
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_HTML_HEADER' ))
2017-12-19 11:40:29 +01:00
{
2017-12-19 12:54:10 +01:00
$htmlheadercontent = @ file_get_contents ( $filehtmlheader );
2017-12-19 11:40:29 +01:00
// Clean the php htmlheader file to remove php code and get only html part
2017-12-19 12:54:10 +01:00
$htmlheadercontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $htmlheadercontent );
2017-12-19 11:40:29 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$htmlheadercontent = GETPOST ( 'WEBSITE_HTML_HEADER' , 'none' );
2017-12-19 11:40:29 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $htmlheadercontent ))
2017-12-19 12:54:10 +01:00
{
2019-11-12 00:15:34 +01:00
$htmlheadercontent = " <html> \n " ;
$htmlheadercontent .= $htmlheadercontentdefault ;
$htmlheadercontent .= " </html> " ;
2017-12-19 12:54:10 +01:00
}
2020-05-21 09:07:10 +02:00
else {
2017-12-19 16:16:31 +01:00
$htmlheadercontent = preg_replace ( '/^\s*<html>/ims' , '' , $htmlheadercontent );
$htmlheadercontent = preg_replace ( '/<\/html>\s*$/ims' , '' , $htmlheadercontent );
2019-11-12 00:15:34 +01:00
$htmlheadercontent = '<html>' . " \n " . trim ( $htmlheadercontent ) . " \n " . '</html>' ;
2017-12-19 16:16:31 +01:00
}
2017-10-07 13:09:31 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_ROBOT' ))
2017-12-19 11:40:29 +01:00
{
$robotcontent = @ file_get_contents ( $filerobot );
// Clean the php htmlheader file to remove php code and get only html part
$robotcontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $robotcontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$robotcontent = GETPOST ( 'WEBSITE_ROBOT' , 'nothtml' );
2017-12-19 11:40:29 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $robotcontent ))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$robotcontent .= " # Robot file. Generated with " . DOL_APPLICATION_TITLE . " \n " ;
$robotcontent .= " User-agent: * \n " ;
$robotcontent .= " Allow: /public/ \n " ;
$robotcontent .= " Disallow: /administrator/ \n " ;
2017-10-07 13:09:31 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_HTACCESS' ))
2017-12-19 11:40:29 +01:00
{
$htaccesscontent = @ file_get_contents ( $filehtaccess );
// Clean the php htaccesscontent file to remove php code and get only html part
$htaccesscontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $htaccesscontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$htaccesscontent = GETPOST ( 'WEBSITE_HTACCESS' , 'nohtml' );
2017-12-19 11:40:29 +01:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $htaccesscontent ))
2017-10-07 13:09:31 +02:00
{
2019-11-12 00:15:34 +01:00
$htaccesscontent .= " # Order allow,deny \n " ;
$htaccesscontent .= " # Deny from all \n " ;
2017-10-07 13:09:31 +02:00
}
2019-08-12 17:34:18 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_MANIFEST_JSON' ))
2019-08-12 17:34:18 +02:00
{
$manifestjsoncontent = @ file_get_contents ( $filemanifestjson );
// Clean the manifestjson file to remove php code and get only html part
$manifestjsoncontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $manifestjsoncontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$manifestjsoncontent = GETPOST ( 'WEBSITE_MANIFEST_JSON' , 'none' );
2019-08-12 17:34:18 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $manifestjsoncontent ))
2019-08-12 17:34:18 +02:00
{
//$manifestjsoncontent.="";
}
2017-07-23 17:44:26 +02:00
2019-11-12 00:15:34 +01:00
if ( ! GETPOSTISSET ( 'WEBSITE_README' ))
2019-08-15 00:55:47 +02:00
{
$readmecontent = @ file_get_contents ( $filereadme );
// Clean the readme file to remove php code and get only html part
$readmecontent = preg_replace ( '/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims' , '' , $readmecontent );
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
$readmecontent = GETPOST ( 'WEBSITE_README' , 'none' );
2019-08-15 00:55:47 +02:00
}
2019-11-12 00:15:34 +01:00
if ( ! trim ( $readmecontent ))
2019-08-15 00:55:47 +02:00
{
//$readmecontent.="";
}
2017-10-07 13:09:31 +02:00
dol_fiche_head ();
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
print '<!-- Edit CSS -->' . " \n " ;
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
// Website
2020-02-21 16:37:07 +01:00
print '<tr><td class="titlefieldcreate fieldrequired">' ;
2017-10-07 13:09:31 +02:00
print $langs -> trans ( 'WebSite' );
print '</td><td>' ;
2018-07-22 17:18:35 +02:00
print $websitekey ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2016-04-27 09:41:42 +02:00
2020-02-19 18:32:04 +01:00
// Main language
2020-02-21 16:37:07 +01:00
print '<tr><td class="tdtop fieldrequired">' ;
2020-04-10 10:59:32 +02:00
$htmltext = '' ;
2020-02-19 18:32:04 +01:00
print $form -> textwithpicto ( $langs -> trans ( 'MainLanguage' ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'WEBSITE_LANG' );
print '</td><td>' ;
2020-02-21 11:36:16 +01:00
print $formadmin -> select_language (( GETPOSTISSET ( 'WEBSITE_LANG' ) ? GETPOST ( 'WEBSITE_LANG' , 'aZ09comma' ) : ( $object -> lang ? $object -> lang : '0' )), 'WEBSITE_LANG' , 0 , null , 1 , 0 , 0 , 'minwidth300' , 2 , 0 , 0 , array (), 1 );
2020-02-19 18:32:04 +01:00
print '</td>' ;
print '</tr>' ;
// Other languages
print '<tr><td class="tdtop">' ;
2020-02-21 17:53:37 +01:00
$htmltext = '' ;
2020-02-19 18:32:04 +01:00
print $form -> textwithpicto ( $langs -> trans ( 'OtherLanguages' ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'WEBSITE_OTHERLANG' );
print '</td><td>' ;
print '<input type="text" class="flat" value="' . ( GETPOSTISSET ( 'WEBSITE_OTHERLANG' ) ? GETPOST ( 'WEBSITE_OTHERLANG' , 'alpha' ) : $object -> otherlang ) . '" name="WEBSITE_OTHERLANG">' ;
print '</td>' ;
print '</tr>' ;
2019-08-12 17:34:18 +02:00
// VirtualHost
print '<tr><td class="tdtop">' ;
$htmltext = $langs -> trans ( " SetHereVirtualHost " , DOL_DATA_ROOT . '/website/<i>' . $websitekey . '</i>' );
2019-11-12 00:15:34 +01:00
$htmltext .= '<br>' ;
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " ReadPerm " ), DOL_DOCUMENT_ROOT );
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " WritePerm " ), DOL_DATA_ROOT . '/website<br>' . DOL_DATA_ROOT . '/medias' );
2019-08-12 17:34:18 +02:00
print $form -> textwithpicto ( $langs -> trans ( 'Virtualhost' ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'virtualhosttooltip' );
print '</td><td>' ;
print '<input type="text" class="flat" value="' . ( GETPOSTISSET ( 'virtualhost' ) ? GETPOST ( 'virtualhost' , 'alpha' ) : $virtualurl ) . '" name="virtualhost">' ;
print '</td>' ;
print '</tr>' ;
2017-10-07 13:09:31 +02:00
// CSS file
print '<tr><td class="tdtop">' ;
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " CSSContentTooltipHelp " );
2019-08-14 23:47:01 +02:00
print $form -> textwithpicto ( $langs -> trans ( 'WEBSITE_CSS_INLINE' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'csstooltip' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2017-07-19 16:38:00 +02:00
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_CSS_INLINE' , $csscontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2017-07-19 16:38:00 +02:00
print $doleditor -> Create ( 1 , '' , true , 'CSS' , 'css' );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2016-05-01 16:34:50 +02:00
2017-10-07 13:09:31 +02:00
// JS file
print '<tr><td class="tdtop">' ;
print $langs -> trans ( 'WEBSITE_JS_INLINE' );
print '</td><td>' ;
2017-10-07 03:08:01 +02:00
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_JS_INLINE' , $jscontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2017-10-07 03:08:01 +02:00
print $doleditor -> Create ( 1 , '' , true , 'JS' , 'javascript' );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-10-07 03:08:01 +02:00
2017-10-07 13:09:31 +02:00
// Common HTML header
2017-07-19 16:38:00 +02:00
print '<tr><td class="tdtop">' ;
2019-08-14 23:57:44 +02:00
print $langs -> trans ( 'WEBSITE_HTML_HEADER' );
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " Example " ) . ' :<br>' ;
$htmlhelp .= dol_htmlentitiesbr ( $htmlheadercontentdefault );
2019-08-14 23:57:44 +02:00
$textwithhelp = $form -> textwithpicto ( '' , $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'htmlheadertooltip' );
2019-11-12 00:15:34 +01:00
$htmlhelp2 = $langs -> trans ( " LinkAndScriptsHereAreNotLoadedInEditor " ) . '<br>' ;
2019-08-14 23:57:44 +02:00
print $form -> textwithpicto ( $textwithhelp , $htmlhelp2 , 1 , 'warning' , '' , 0 , 2 , 'htmlheadertooltip2' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2017-07-19 16:38:00 +02:00
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_HTML_HEADER' , $htmlheadercontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2017-07-19 16:38:00 +02:00
print $doleditor -> Create ( 1 , '' , true , 'HTML Header' , 'html' );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-07-23 17:44:26 +02:00
2017-10-07 13:09:31 +02:00
// Robot file
2017-07-23 17:44:26 +02:00
print '<tr><td class="tdtop">' ;
2017-10-07 13:09:31 +02:00
print $langs -> trans ( 'WEBSITE_ROBOT' );
print '</td><td>' ;
2017-07-23 17:44:26 +02:00
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_ROBOT' , $robotcontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2017-12-10 19:54:04 +01:00
print $doleditor -> Create ( 1 , '' , true , 'Robot file' , 'text' );
2017-07-23 17:44:26 +02:00
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-07-23 17:44:26 +02:00
2017-10-07 13:09:31 +02:00
// .htaccess
2017-07-23 17:44:26 +02:00
print '<tr><td class="tdtop">' ;
2017-10-07 13:09:31 +02:00
print $langs -> trans ( 'WEBSITE_HTACCESS' );
print '</td><td>' ;
2017-07-23 17:44:26 +02:00
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_HTACCESS' , $htaccesscontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2017-12-10 19:54:04 +01:00
print $doleditor -> Create ( 1 , '' , true , $langs -> trans ( " File " ) . ' .htaccess' , 'text' );
2017-07-23 17:44:26 +02:00
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-07-10 23:44:46 +02:00
2019-08-12 17:34:18 +02:00
// Manifest.json
2019-01-23 14:57:43 +01:00
print '<tr><td class="tdtop">' ;
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " Example " ) . ' :<br>' ;
$htmlhelp .= dol_htmlentitiesbr ( $manifestjsoncontentdefault );
2019-08-12 17:34:18 +02:00
print $form -> textwithpicto ( $langs -> trans ( 'WEBSITE_MANIFEST_JSON' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'manifestjsontooltip' );
print '</td><td>' ;
2019-12-07 13:09:55 +01:00
print $langs -> trans ( " UseManifest " ) . ': ' . $form -> selectyesno ( 'use_manifest' , $website -> use_manifest , 1 ) . '<br>' ;
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_MANIFEST_JSON' , $manifestjsoncontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2019-08-12 17:34:18 +02:00
print $doleditor -> Create ( 1 , '' , true , $langs -> trans ( " File " ) . ' manifest.json' , 'text' );
print '</td></tr>' ;
2019-01-23 14:57:43 +01:00
2019-08-15 00:55:47 +02:00
// README.md
print '<tr><td class="tdtop">' ;
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " EnterHereLicenseInformation " );
2019-08-15 00:55:47 +02:00
print $form -> textwithpicto ( $langs -> trans ( 'WEBSITE_README' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'readmetooltip' );
print '</td><td>' ;
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'WEBSITE_README' , $readmecontent , '' , '220' , 'ace' , 'In' , true , false , 'ace' , 0 , '100%' , '' );
2019-08-15 00:55:47 +02:00
print $doleditor -> Create ( 1 , '' , true , $langs -> trans ( " File " ) . ' README.md' , 'text' );
print '</td></tr>' ;
2020-05-23 12:51:44 +02:00
// RSS
print '<tr><td class="tdtop">' ;
2020-05-23 12:57:58 +02:00
$htmlhelp = $langs -> trans ( 'RSSFeedDesc' );
print $form -> textwithpicto ( $langs -> trans ( 'RSSFeed' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , '' );
2020-05-23 12:51:44 +02:00
print '</td><td>' ;
2020-05-23 12:57:58 +02:00
print '/wrapper.php?rss=1[&l=XX][&limit=123]' ;
2020-05-23 12:51:44 +02:00
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
print '</table>' ;
2016-05-01 16:34:50 +02:00
2017-10-07 13:09:31 +02:00
dol_fiche_end ();
2016-05-01 16:34:50 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
2016-05-01 16:34:50 +02:00
2017-10-07 13:09:31 +02:00
print '<br>' ;
2016-05-01 16:34:50 +02:00
}
2018-05-25 17:52:24 +02:00
2017-09-01 12:19:55 +02:00
if ( $action == 'createsite' )
{
2017-10-07 13:09:31 +02:00
print '<div class="fiche">' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '<br>' ;
2017-09-01 12:19:55 +02:00
/* $h = 0 ;
$head = array ();
2017-10-20 21:39:19 +02:00
$head [ $h ][ 0 ] = dol_buildpath ( '/website/index.php' , 1 ) . '?id=' . $object -> id ;
2017-09-01 12:19:55 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " AddSite " );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
dol_fiche_head ( $head , 'card' , $langs -> trans ( " AddSite " ), - 1 , 'globe' );
*/
2018-09-09 15:52:55 +02:00
if ( $action == 'createcontainer' ) print load_fiche_titre ( $langs -> trans ( " AddSite " ));
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '<!-- Add site -->' . " \n " ;
//print '<div class="fichecenter">';
2017-09-01 12:19:55 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2017-09-01 12:19:55 +02:00
2020-02-19 18:32:04 +01:00
$siteref = $sitedesc = $sitelang = $siteotherlang = '' ;
2019-11-12 00:15:34 +01:00
if ( GETPOST ( 'WEBSITE_REF' )) $siteref = GETPOST ( 'WEBSITE_REF' , 'alpha' );
if ( GETPOST ( 'WEBSITE_DESCRIPTION' )) $sitedesc = GETPOST ( 'WEBSITE_DESCRIPTION' , 'alpha' );
2020-02-19 18:32:04 +01:00
if ( GETPOST ( 'WEBSITE_LANG' )) $sitelang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
if ( GETPOST ( 'WEBSITE_OTHERLANG' )) $siteotherlang = GETPOST ( 'WEBSITE_OTHERLANG' , 'aZ09comma' );
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '<tr><td class="titlefieldcreate fieldrequired">' ;
print $langs -> trans ( 'Ref' );
print '</td><td>' ;
2020-02-06 23:35:04 +01:00
print '<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="' . dol_escape_htmltag ( $siteref ) . '" autofocus>' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-09-01 12:19:55 +02:00
2020-02-21 16:37:07 +01:00
print '<tr><td class="fieldrequired">' ;
print $langs -> trans ( 'MainLanguage' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2020-02-21 16:37:07 +01:00
$shortlangcode = preg_replace ( '/[_-].*$/' , '' , trim ( $langs -> defaultlang ));
print $formadmin -> select_language (( GETPOSTISSET ( 'WEBSITE_LANG' ) ? GETPOST ( 'WEBSITE_LANG' , 'aZ09comma' ) : $shortlangcode ), 'WEBSITE_LANG' , 0 , null , 1 , 0 , 0 , 'minwidth300' , 2 , 0 , 0 , array (), 1 );
2020-02-19 18:32:04 +01:00
print '</td></tr>' ;
print '<tr><td>' ;
2020-02-21 16:37:07 +01:00
print $langs -> trans ( 'Description' );
2020-02-19 18:32:04 +01:00
print '</td><td>' ;
2020-02-21 16:37:07 +01:00
print '<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="' . dol_escape_htmltag ( $sitedesc ) . '">' ;
2020-02-19 18:32:04 +01:00
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( 'OtherLanguages' );
print '</td><td>' ;
print '<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="' . dol_escape_htmltag ( $siteotherlang ) . '">' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '<tr><td>' ;
2019-01-23 14:57:43 +01:00
2018-02-19 21:31:03 +01:00
$htmltext = $langs -> trans ( " SetHereVirtualHost " , DOL_DATA_ROOT . '/website/<i>websiteref</i>' );
2019-11-12 00:15:34 +01:00
$htmltext .= '<br>' ;
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " ReadPerm " ), DOL_DOCUMENT_ROOT );
$htmltext .= '<br>' . $langs -> trans ( " CheckVirtualHostPerms " , $langs -> transnoentitiesnoconv ( " WritePerm " ), DOL_DATA_ROOT . '/website<br>' . DOL_DATA_ROOT . '/medias' );
2018-02-19 21:57:30 +01:00
2019-01-23 14:57:43 +01:00
print $form -> textwithpicto ( $langs -> trans ( 'Virtualhost' ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'virtualhosttooltip' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2019-01-27 11:55:16 +01:00
print '<input type="text" class="flat minwidth300" name="virtualhost" value="' . dol_escape_htmltag ( GETPOST ( 'virtualhost' , 'alpha' )) . '">' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '</table>' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
if ( $action == 'createsite' )
{
print '<div class="center">' ;
2017-09-01 12:19:55 +02:00
2017-12-12 01:40:34 +01:00
print '<input class="button" type="submit" name="addcontainer" value="' . $langs -> trans ( " Create " ) . '">' ;
2017-10-07 13:09:31 +02:00
print '<input class="button" type="submit" name="preview" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
}
2017-09-01 12:19:55 +02:00
//print '</div>';
2017-10-07 13:09:31 +02:00
//dol_fiche_end();
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
2017-09-01 12:19:55 +02:00
2017-10-07 13:09:31 +02:00
print '<br>' ;
2017-09-01 12:19:55 +02:00
}
2018-08-15 14:24:33 +02:00
if ( $action == 'importsite' )
{
2018-08-16 00:03:19 +02:00
print '<div class="fiche">' ;
print '<br>' ;
2018-09-09 15:52:55 +02:00
print load_fiche_titre ( $langs -> trans ( " ImportSite " ));
2018-08-16 00:03:19 +02:00
dol_fiche_head ( array (), '0' , '' , - 1 );
2019-08-12 22:19:24 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " ZipOfWebsitePackageToImport " ) . '</span><br><br>' ;
2018-08-15 14:24:33 +02:00
2020-05-19 03:36:29 +02:00
print '<input type="hidden" name="max_file_size" value="' . $conf -> maxfilesize . '">' ;
2018-08-16 00:03:19 +02:00
print '<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">' ;
print '<input type="submit" class="button" name="buttonsubmitimportfile" value="' . dol_escape_htmltag ( $langs -> trans ( " Upload " )) . '">' ;
2018-11-20 13:41:38 +01:00
print '<input type="submit" class="button" name="preview" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
2018-08-15 14:24:33 +02:00
2019-08-12 22:19:24 +02:00
print '<br><br><br>' ;
print '<span class="opacitymedium">' . $langs -> trans ( " ZipOfWebsitePackageToLoad " ) . '</span><br><br>' ;
showWebsiteTemplates ( $website );
2018-08-16 00:03:19 +02:00
dol_fiche_end ();
print '</div>' ;
print '<br>' ;
2018-08-15 14:24:33 +02:00
}
2018-05-25 17:52:24 +02:00
2017-12-12 01:40:34 +01:00
if ( $action == 'editmeta' || $action == 'createcontainer' )
2016-05-01 16:34:50 +02:00
{
2017-10-07 13:09:31 +02:00
print '<div class="fiche">' ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
print '<br>' ;
2017-07-02 23:38:19 +02:00
2017-09-01 12:19:55 +02:00
/* $h = 0 ;
2017-08-03 01:45:31 +02:00
$head = array ();
2017-10-20 21:39:19 +02:00
$head [ $h ][ 0 ] = dol_buildpath ( '/website/index.php' , 1 ) . '?id=' . $object -> id ;
2017-08-03 01:45:31 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " AddPage " );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
2017-09-01 12:19:55 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " AddPage " ), - 1 , 'globe' );
*/
2018-09-09 15:52:55 +02:00
if ( $action == 'createcontainer' ) print load_fiche_titre ( $langs -> trans ( " AddPage " ));
2017-07-02 23:38:19 +02:00
2017-12-12 01:40:34 +01:00
print '<!-- Edit or create page/container -->' . " \n " ;
2017-10-07 13:09:31 +02:00
//print '<div class="fichecenter">';
2017-08-03 01:45:31 +02:00
2019-10-31 21:09:33 +01:00
$hiddenfromfetchingafterload = ' hideobject' ;
$hiddenmanuallyafterload = ' hideobject' ;
if ( GETPOST ( 'radiocreatefrom' ) == 'checkboxcreatefromfetching' ) $hiddenfromfetchingafterload = '' ;
if ( GETPOST ( 'radiocreatefrom' ) == 'checkboxcreatemanually' ) $hiddenmanuallyafterload = '' ;
if ( $action == 'editmeta' || empty ( $conf -> use_javascript_ajax )) { // No autohide/show in such case
2019-11-12 00:15:34 +01:00
$hiddenfromfetchingafterload = '' ;
$hiddenmanuallyafterload = '' ;
2019-10-31 21:09:33 +01:00
}
2018-02-19 14:56:37 +01:00
if ( $action == 'createcontainer' )
2017-10-07 13:09:31 +02:00
{
2018-02-19 14:56:37 +01:00
print '<br>' ;
2019-11-12 00:15:34 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"' . ( GETPOST ( 'radiocreatefrom' ) == 'checkboxcreatefromfetching' ? ' checked' : '' ) . '> ' ;
2019-11-24 20:59:17 +01:00
print '<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">' . $langs -> trans ( " CreateByFetchingExternalPage " ) . '</span></label><br>' ;
2019-10-31 21:09:33 +01:00
print '<hr class="tablecheckboxcreatefromfetching' . $hiddenfromfetchingafterload . '">' ;
print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching' . $hiddenfromfetchingafterload . '">' ;
2018-02-19 14:56:37 +01:00
print '<tr><td class="titlefield">' ;
print $langs -> trans ( " URL " );
print '</td><td>' ;
2018-09-20 14:36:13 +02:00
print info_admin ( $langs -> trans ( " OnlyEditionOfSourceForGrabbedContentFuture " ), 0 , 0 , 'warning' );
2019-01-27 11:55:16 +01:00
print '<input class="flat minwidth500" type="text" name="externalurl" value="' . dol_escape_htmltag ( GETPOST ( 'externalurl' , 'alpha' )) . '" placeholder="https://externalsite/pagetofetch"> ' ;
2018-11-27 18:04:45 +01:00
print '<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> ' . $langs -> trans ( " GrabImagesInto " );
2018-02-19 14:56:37 +01:00
print ' ' ;
print $langs -> trans ( " ImagesShouldBeSavedInto " ) . ' ' ;
2019-11-12 00:15:34 +01:00
$arraygrabimagesinto = array ( 'root' => $langs -> trans ( " WebsiteRootOfImages " ), 'subpage' => $langs -> trans ( " SubdirOfPage " ));
print $form -> selectarray ( 'grabimagesinto' , $arraygrabimagesinto , GETPOSTISSET ( 'grabimagesinto' ) ? GETPOST ( 'grabimagesinto' ) : 'root' );
2018-02-19 14:56:37 +01:00
print '<br>' ;
print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="' . dol_escape_htmltag ( $langs -> trans ( " FetchAndCreate " )) . '">' ;
print '</td></tr>' ;
print '</table>' ;
print '<br>' ;
2019-11-12 00:15:34 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"' . ( GETPOST ( 'radiocreatefrom' ) == 'checkboxcreatemanually' ? ' checked' : '' ) . '> ' ;
2019-11-24 20:59:17 +01:00
print '<label for="checkboxcreatemanually"><span class="opacitymediumxx">' . $langs -> trans ( " OrEnterPageInfoManually " ) . '</span></label><br>' ;
2019-10-31 21:09:33 +01:00
print '<hr class="tablecheckboxcreatemanually' . $hiddenmanuallyafterload . '">' ;
2017-10-07 13:09:31 +02:00
}
2017-10-01 21:29:49 +02:00
2019-10-31 21:09:33 +01:00
print '<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually' . $hiddenmanuallyafterload . '">' ;
2017-08-20 19:47:55 +02:00
2017-12-12 01:40:34 +01:00
if ( $action != 'createcontainer' )
2017-10-07 13:09:31 +02:00
{
2018-02-28 14:36:22 +01:00
print '<tr><td class="titlefield">' ;
2017-10-07 13:09:31 +02:00
print $langs -> trans ( 'IDOfPage' );
print '</td><td>' ;
print $pageid ;
print '</td></tr>' ;
print '<tr><td class="titlefield">' ;
2018-09-20 14:36:13 +02:00
print $langs -> trans ( 'InternalURLOfPage' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2018-07-22 17:18:35 +02:00
print '/public/website/index.php?website=' . urlencode ( $websitekey ) . '&pageid=' . urlencode ( $pageid );
2019-10-31 21:09:33 +01:00
//if ($objectpage->grabbed_from) print ' - <span class="opacitymedium">'.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.'</span>';
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2019-11-12 00:15:34 +01:00
$type_container = $objectpage -> type_container ;
$pageurl = $objectpage -> pageurl ;
$pagealiasalt = $objectpage -> aliasalt ;
$pagetitle = $objectpage -> title ;
$pagedescription = $objectpage -> description ;
$pageimage = $objectpage -> image ;
$pagekeywords = $objectpage -> keywords ;
$pagelang = $objectpage -> lang ;
$pagehtmlheader = $objectpage -> htmlheader ;
$pagedatecreation = $objectpage -> date_creation ;
$pagedatemodification = $objectpage -> date_modification ;
$pageauthorid = $objectpage -> fk_user_creat ;
$pageusermodifid = $objectpage -> fk_user_modif ;
2020-03-12 20:50:36 +01:00
$pageauthoralias = $objectpage -> author_alias ;
2020-05-14 18:14:55 +02:00
$pagestatus = $objectpage -> status ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-06-06 23:12:09 +02:00
$type_container = 'page' ;
2019-11-12 00:15:34 +01:00
$pagedatecreation = dol_now ();
$pageauthorid = $user -> id ;
$pageusermodifid = 0 ;
2020-03-12 20:50:36 +01:00
$pageauthoralias = '' ;
2020-05-14 18:14:55 +02:00
$pagestatus = 1 ;
2019-11-12 00:15:34 +01:00
}
if ( GETPOST ( 'WEBSITE_TITLE' , 'alpha' )) $pagetitle = GETPOST ( 'WEBSITE_TITLE' , 'alpha' );
if ( GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' )) $pageurl = GETPOST ( 'WEBSITE_PAGENAME' , 'alpha' );
if ( GETPOST ( 'WEBSITE_ALIASALT' , 'alpha' )) $pagealiasalt = GETPOST ( 'WEBSITE_ALIASALT' , 'alpha' );
if ( GETPOST ( 'WEBSITE_DESCRIPTION' , 'alpha' )) $pagedescription = GETPOST ( 'WEBSITE_DESCRIPTION' , 'alpha' );
if ( GETPOST ( 'WEBSITE_IMAGE' , 'alpha' )) $pageimage = GETPOST ( 'WEBSITE_IMAGE' , 'alpha' );
if ( GETPOST ( 'WEBSITE_KEYWORDS' , 'alpha' )) $pagekeywords = GETPOST ( 'WEBSITE_KEYWORDS' , 'alpha' );
if ( GETPOST ( 'WEBSITE_LANG' , 'aZ09' )) $pagelang = GETPOST ( 'WEBSITE_LANG' , 'aZ09' );
2020-05-14 18:14:55 +02:00
if ( GETPOST ( 'htmlheader' , 'none' )) $pagehtmlheader = GETPOST ( 'htmlheader' , 'none' );
2016-04-27 09:41:42 +02:00
2020-05-26 00:19:32 +02:00
// Type of container
print '<tr><td class="titlefield fieldrequired">' ;
print $langs -> trans ( 'WEBSITE_TYPE_CONTAINER' );
print '</td><td>' ;
2020-05-26 12:53:58 +02:00
print img_picto ( '' , 'object_technic' , 'class="paddingrightonly"' ) . ' ' ;
$formwebsite -> selectTypeOfContainer ( 'WEBSITE_TYPE_CONTAINER' , ( GETPOST ( 'WEBSITE_TYPE_CONTAINER' , 'alpha' ) ? GETPOST ( 'WEBSITE_TYPE_CONTAINER' , 'alpha' ) : $type_container ));
2020-05-26 00:19:32 +02:00
print '</td></tr>' ;
if ( $action == 'createcontainer' )
{
print '<tr><td class="titlefield fieldrequired">' ;
print $langs -> trans ( 'WEBSITE_PAGE_EXAMPLE' );
print '</td><td>' ;
print $formwebsite -> selectSampleOfContainer ( 'sample' , ( GETPOSTISSET ( 'sample' ) ? GETPOST ( 'sample' , 'alpha' ) : 'empty' ));
print '</td></tr>' ;
}
2018-05-15 11:36:39 +02:00
// Title
print '<tr><td class="fieldrequired">' ;
print $langs -> trans ( 'WEBSITE_TITLE' );
print '</td><td>' ;
2019-10-31 21:09:33 +01:00
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="' . dol_escape_htmltag ( $pagetitle ) . '" autofocus>' ;
2018-05-15 11:36:39 +02:00
print '</td></tr>' ;
// Alias
2018-02-28 14:36:22 +01:00
print '<tr><td class="titlefieldcreate fieldrequired">' ;
print $langs -> trans ( 'WEBSITE_PAGENAME' );
2017-12-02 13:24:21 +01:00
print '</td><td>' ;
2018-06-07 19:12:18 +02:00
print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="' . dol_escape_htmltag ( $pageurl ) . '">' ;
2017-12-02 13:24:21 +01:00
print '</td></tr>' ;
2020-05-26 00:19:32 +02:00
print '<tr><td class="titlefieldcreate">' ;
$htmlhelp = $langs -> trans ( " WEBSITE_ALIASALTDesc " );
print $form -> textwithpicto ( $langs -> trans ( 'WEBSITE_ALIASALT' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'aliastooltip' );
2018-02-20 18:10:11 +01:00
print '</td><td>' ;
2020-05-26 00:19:32 +02:00
print '<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="' . dol_escape_htmltag ( $pagealiasalt ) . '">' ;
2018-02-20 18:10:11 +01:00
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
print '<tr><td>' ;
print $langs -> trans ( 'WEBSITE_DESCRIPTION' );
print '</td><td>' ;
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="' . dol_escape_htmltag ( $pagedescription ) . '">' ;
print '</td></tr>' ;
2018-11-20 16:48:34 +01:00
print '<tr><td>' ;
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " WEBSITE_IMAGEDesc " );
2018-12-18 11:03:23 +01:00
print $form -> textwithpicto ( $langs -> trans ( 'WEBSITE_IMAGE' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'imagetooltip' );
2018-11-20 16:48:34 +01:00
print '</td><td>' ;
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="' . dol_escape_htmltag ( $pageimage ) . '">' ;
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
print '<tr><td>' ;
print $langs -> trans ( 'WEBSITE_KEYWORDS' );
print '</td><td>' ;
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="' . dol_escape_htmltag ( $pagekeywords ) . '">' ;
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( 'Language' );
print '</td><td>' ;
2020-02-20 01:08:53 +01:00
$onlykeys = array ();
if ( $object -> lang ) $onlykeys [ $object -> lang ] = $object -> lang ;
else $onlykeys [ $langs -> defaultlang ] = $langs -> defaultlang ;
if ( $object -> otherlang ) {
$tmparray = explode ( ',' , $object -> otherlang );
2020-02-21 17:53:37 +01:00
foreach ( $tmparray as $key ) {
2020-02-20 01:08:53 +01:00
$tmpkey = trim ( $key );
if ( strlen ( $key ) == 2 ) {
2020-02-21 11:36:16 +01:00
$tmpkey = strtolower ( $key );
2020-02-20 01:08:53 +01:00
}
$onlykeys [ $tmpkey ] = $tmpkey ;
}
}
if ( empty ( $object -> lang ) && empty ( $object -> otherlang )) {
2020-02-21 17:53:37 +01:00
$onlykeys = null ; // We keep full list of languages
2020-02-20 01:08:53 +01:00
}
2020-02-21 11:36:16 +01:00
print $formadmin -> select_language ( $pagelang ? $pagelang : '' , 'WEBSITE_LANG' , 0 , null , '1' , 0 , 0 , 'minwidth200' , 0 , 0 , 0 , $onlykeys , 1 );
2020-02-20 01:08:53 +01:00
$htmltext = $langs -> trans ( " AvailableLanguagesAreDefinedIntoWebsiteProperties " );
print $form -> textwithpicto ( '' , $htmltext );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2019-10-31 21:09:33 +01:00
// Translation of
2019-11-12 00:15:34 +01:00
$translationof = 0 ;
$translatedby = 0 ;
2019-10-31 21:09:33 +01:00
print '<!-- Translation of --><tr><td>' ;
print $langs -> trans ( 'TranslationLinks' );
print '</td><td>' ;
if ( $action != 'createcontainer' )
{
2018-10-14 18:44:29 +02:00
// Has translation pages
2019-11-12 00:15:34 +01:00
$sql = 'SELECT rowid, lang from ' . MAIN_DB_PREFIX . 'website_page where fk_page = ' . $objectpage -> id ;
2018-10-14 18:44:29 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num_rows = $db -> num_rows ( $resql );
if ( $num_rows > 0 )
{
2019-11-16 12:54:05 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( 'ThisPageHasTranslationPages' ) . ':</span>' ;
2019-11-12 00:15:34 +01:00
$i = 0 ;
2019-11-16 12:17:37 +01:00
$tmppage = new WebsitePage ( $db );
2019-11-16 12:54:05 +01:00
$tmpstring = '' ;
2018-10-14 18:44:29 +02:00
while ( $obj = $db -> fetch_object ( $resql ))
{
2019-11-16 12:17:37 +01:00
$result = $tmppage -> fetch ( $obj -> rowid );
if ( $result > 0 ) {
2019-11-16 12:54:05 +01:00
if ( $i > 0 ) $tmpstring .= '<br>' ;
$tmpstring .= $tmppage -> getNomUrl ( 1 ) . ' (' . $tmppage -> lang . ')' ;
2019-11-16 12:17:37 +01:00
$translatedby ++ ;
$i ++ ;
}
2018-10-14 18:44:29 +02:00
}
2019-11-16 12:54:05 +01:00
if ( $i > 1 ) print '<br>' ;
else print ' ' ;
print $tmpstring ;
2018-10-14 18:44:29 +02:00
}
}
else dol_print_error ( $db );
}
2019-10-31 21:27:25 +01:00
if ( empty ( $translatedby ) && ( $action == 'editmeta' || $action == 'createcontainer' || $objectpage -> fk_page > 0 ))
{
2019-11-12 00:15:34 +01:00
$sourcepage = new WebsitePage ( $db );
2019-10-31 21:27:25 +01:00
$result = $sourcepage -> fetch ( $objectpage -> fk_page );
if ( $result == 0 )
{
// not found, we can reset value to clean database
}
elseif ( $result > 0 )
{
2019-11-16 12:43:32 +01:00
$translationof = $objectpage -> fk_page ;
2019-10-31 21:27:25 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( 'ThisPageIsTranslationOf' ) . '</span> ' ;
2019-11-16 12:43:32 +01:00
print $formwebsite -> selectContainer ( $website , 'pageidfortranslation' , ( $translationof ? $translationof : - 1 ), 1 , $action , 'minwidth300' , array ( $objectpage -> id ));
2019-11-16 12:54:05 +01:00
if ( $translationof > 0 ) {
print $sourcepage -> getNomUrl ( 2 ) . ' (' . $sourcepage -> lang . ')' ;
}
2019-10-31 21:27:25 +01:00
}
}
2019-10-31 21:09:33 +01:00
print '</td></tr>' ;
2018-10-14 18:44:29 +02:00
2020-05-26 00:19:32 +02:00
// Categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
{
$langs -> load ( 'categories' );
if ( ! GETPOSTISSET ( 'categories' )) {
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_WEBSITE_PAGE , '' , null , null , null , 1 );
$c = new Categorie ( $db );
$cats = $c -> containing ( $objectpage -> id , Categorie :: TYPE_WEBSITE_PAGE );
$arrayselected = array ();
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_WEBSITE_PAGE , '' , 'parent' , null , null , 1 );
}
print '<tr class="visibleifsupplier"><td class="toptd">' . $form -> editfieldkey ( 'Categories' , 'categories' , '' , $objectpage , 0 ) . '</td><td colspan="3">' ;
print img_picto ( '' , 'category' , 'class="paddingright"' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , ( GETPOSTISSET ( 'categories' ) ? GETPOST ( 'categories' , 'array' ) : $arrayselected ), null , null , null , null , " 90% " );
print " </td></tr> " ;
}
2018-02-28 14:36:22 +01:00
2019-11-12 00:15:34 +01:00
$fuser = new User ( $db );
2018-09-24 17:12:51 +02:00
print '<tr><td>' ;
print $langs -> trans ( 'Author' );
print '</td><td>' ;
2019-01-15 10:53:28 +01:00
if ( $pageauthorid > 0 )
{
$fuser -> fetch ( $pageauthorid );
print $fuser -> getNomUrl ( 1 );
2020-04-20 02:14:43 +02:00
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " Unknown " ) . '</span>' ;
2019-01-15 10:53:28 +01:00
}
2018-09-24 17:12:51 +02:00
print '</td></tr>' ;
2020-03-12 20:50:36 +01:00
print '<tr><td>' ;
print $langs -> trans ( 'PublicAuthorAlias' );
print '</td><td>' ;
print '<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="' . dol_escape_htmltag ( $pageauthoralias ) . '">' ;
print '</td></tr>' ;
2018-09-24 17:12:51 +02:00
print '<tr><td>' ;
print $langs -> trans ( 'DateCreation' );
print '</td><td>' ;
2019-09-06 02:45:00 +02:00
print $form -> selectDate ( $pagedatecreation , 'datecreation' , 1 , 1 , 0 , '' , 1 , 1 );
2019-01-15 10:53:28 +01:00
//print dol_print_date($pagedatecreation, 'dayhour');
2018-09-24 17:12:51 +02:00
print '</td></tr>' ;
if ( $action != 'createcontainer' )
{
2019-01-15 10:53:28 +01:00
print '<tr><td>' ;
2019-08-12 19:01:23 +02:00
print $langs -> trans ( 'UserModif' );
2019-01-15 10:53:28 +01:00
print '</td><td>' ;
if ( $pageusermodifid > 0 )
{
$fuser -> fetch ( $pageusermodifid );
print $fuser -> getNomUrl ( 1 );
}
print '</td></tr>' ;
print '<tr><td>' ;
2018-09-24 17:12:51 +02:00
print $langs -> trans ( 'DateModification' );
print '</td><td>' ;
2019-01-15 11:14:01 +01:00
print dol_print_date ( $pagedatemodification , 'dayhour' , 'tzuser' );
2018-09-24 17:12:51 +02:00
print '</td></tr>' ;
}
2017-12-10 19:03:18 +01:00
print '<tr><td class="tdhtmlheader tdtop">' ;
2019-11-12 00:15:34 +01:00
$htmlhelp = $langs -> trans ( " EditTheWebSiteForACommonHeader " ) . '<br><br>' ;
$htmlhelp .= $langs -> trans ( " Example " ) . ' :<br>' ;
$htmlhelp .= dol_htmlentitiesbr ( $htmlheadercontentdefault );
2017-12-19 11:40:29 +01:00
print $form -> textwithpicto ( $langs -> trans ( 'HtmlHeaderPage' ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'htmlheadertooltip' );
2017-10-07 13:09:31 +02:00
print '</td><td>' ;
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'htmlheader' , $pagehtmlheader , '' , '120' , 'ace' , 'In' , true , false , 'ace' , ROWS_3 , '100%' , '' );
2017-10-07 13:09:31 +02:00
print $doleditor -> Create ( 1 , '' , true , 'HTML Header' , 'html' );
print '</td></tr>' ;
2016-04-27 09:41:42 +02:00
2020-05-14 18:14:55 +02:00
if ( $action != 'createcontainer' )
{
print '<tr><td>' ;
print $langs -> trans ( 'Status' );
print '</td><td>' ;
print ajax_object_onoff ( $objectpage , 'status' , 'status' , 'Enabled' , 'Disabled' );
//print dol_print_date($pagedatecreation, 'dayhour');
print '</td></tr>' ;
}
2017-10-07 13:09:31 +02:00
print '</table>' ;
2017-12-12 01:40:34 +01:00
if ( $action == 'createcontainer' )
2017-10-07 13:09:31 +02:00
{
2019-10-31 21:09:33 +01:00
print '<div class="center tablecheckboxcreatemanually' . $hiddenmanuallyafterload . '">' ;
2017-08-20 18:50:51 +02:00
2017-12-12 01:40:34 +01:00
print '<input class="button" type="submit" name="addcontainer" value="' . $langs -> trans ( " Create " ) . '">' ;
2017-10-07 13:09:31 +02:00
print '<input class="button" type="submit" name="preview" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2017-08-20 18:50:51 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
}
2017-08-20 18:50:51 +02:00
2018-06-07 19:12:18 +02:00
if ( $action == 'createcontainer' )
{
print ' < script type = " text/javascript " language = " javascript " >
jQuery ( document ) . ready ( function () {
var disableautofillofalias = 0 ;
jQuery ( " #WEBSITE_TITLE " ) . keyup ( function () {
if ( disableautofillofalias == 0 )
{
2019-08-15 16:58:36 +02:00
var valnospecial = jQuery ( " #WEBSITE_TITLE " ) . val ();
valnospecial = valnospecial . replace ( / [ éèê ] / g , \ ' e\ ' ) . replace ( / [ à ] / g , \ ' a\ ' ) . replace ( / [ ù ] / g , \ ' u\ ' ) . replace ( / [ î ] / g , \ ' i\ ' );
valnospecial = valnospecial . replace ( / [ ç ] / g , \ ' c\ ' ) . replace ( / [ ö ] / g , \ ' o\ ' );
valnospecial = valnospecial . replace ( / [ ^ \w ] / gi , \ ' - \ ' ) . toLowerCase ();
2018-06-07 19:12:18 +02:00
valnospecial = valnospecial . replace ( / \ -+/ g , \ ' - \ ' ) . replace ( / \ - $ / , \ ' \ ' );
console . log ( " disableautofillofalias=0 so we replace WEBSITE_TITLE with " + valnospecial );
jQuery ( " #WEBSITE_PAGENAME " ) . val ( valnospecial );
}
});
jQuery ( " #WEBSITE_PAGENAME " ) . keyup ( function () {
disableautofillofalias = 1 ;
});
2019-10-31 21:09:33 +01:00
jQuery ( " #checkboxcreatefromfetching,#checkboxcreatemanually " ) . change ( function () {
console . log ( " we select a method to create a new container " + jQuery ( " #checkboxcreatefromfetching:checked " ) . val ())
if ( typeof ( jQuery ( " #checkboxcreatefromfetching:checked " ) . val ()) != \ ' undefined\ ' )
{
jQuery ( " .tablecheckboxcreatefromfetching " ) . show ();
jQuery ( " .tablecheckboxcreatemanually " ) . hide ();
}
if ( typeof ( jQuery ( " #checkboxcreatemanually:checked " ) . val ()) != \ ' undefined\ ' )
{
jQuery ( " .tablecheckboxcreatefromfetching " ) . hide ();
jQuery ( " .tablecheckboxcreatemanually " ) . show ();
}
});
2018-06-07 19:12:18 +02:00
});
</ script > ' ;
}
2017-08-03 01:45:31 +02:00
//print '</div>';
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
//dol_fiche_end();
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
2016-04-27 09:41:42 +02:00
2017-10-07 13:09:31 +02:00
print '<br>' ;
2016-04-19 11:02:55 +02:00
}
2017-11-18 15:41:30 +01:00
if ( $action == 'editfile' || $action == 'file_manager' )
2016-05-01 16:34:50 +02:00
{
2017-10-07 13:09:31 +02:00
print '<!-- Edit Media -->' . " \n " ;
2019-05-28 16:10:11 +02:00
print '<div class="fiche"><br>' ;
2017-11-05 02:04:05 +01:00
//print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
$module = 'medias' ;
2019-11-12 00:15:34 +01:00
if ( empty ( $url )) $url = DOL_URL_ROOT . '/website/index.php' ; // Must be an url without param
2017-11-19 12:22:01 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/filemanager.tpl.php' ;
2017-11-18 13:09:12 +01:00
print '</div>' ;
2016-05-01 16:34:50 +02:00
}
2016-04-19 11:02:55 +02:00
if ( $action == 'editmenu' )
{
2017-10-07 13:09:31 +02:00
print '<!-- Edit Menu -->' . " \n " ;
print '<div class="center">' . $langs -> trans ( " FeatureNotYetAvailable " ) . '</center>' ;
2016-04-19 11:02:55 +02:00
}
2017-07-22 20:19:10 +02:00
if ( $action == 'editsource' )
{
2018-09-24 15:14:32 +02:00
// Editing with source editor
2017-07-22 20:19:10 +02:00
$contentforedit = '' ;
2018-09-24 15:14:32 +02:00
//$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
//$contentforedit.=$csscontent;
//$contentforedit.='</style>'."\n";
2017-07-22 20:19:10 +02:00
$contentforedit .= $objectpage -> content ;
2018-09-24 15:14:32 +02:00
//var_dump($_SESSION["dol_screenheight"]);
2019-11-12 00:15:34 +01:00
$maxheightwin = 480 ;
2018-09-24 15:14:32 +02:00
if ( isset ( $_SESSION [ " dol_screenheight " ]))
{
2019-11-12 00:15:34 +01:00
if ( $_SESSION [ " dol_screenheight " ] > 680 ) $maxheightwin = $_SESSION [ " dol_screenheight " ] - 400 ;
if ( $_SESSION [ " dol_screenheight " ] > 800 ) $maxheightwin = $_SESSION [ " dol_screenheight " ] - 490 ;
2018-09-24 15:14:32 +02:00
}
//var_dump($_SESSION["dol_screenheight"]);
2017-07-22 20:19:10 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-11-12 00:15:34 +01:00
$doleditor = new DolEditor ( 'PAGE_CONTENT' , $contentforedit , '' , $maxheightwin , 'Full' , '' , true , true , 'ace' , ROWS_5 , '40%' );
2017-07-22 20:46:02 +02:00
$doleditor -> Create ( 0 , '' , false , 'HTML Source' , 'php' );
2017-07-22 20:19:10 +02:00
}
2018-09-24 15:14:32 +02:00
/* if ( $action == 'editcontent' )
2016-04-19 11:02:55 +02:00
{
2018-09-24 15:14:32 +02:00
// Editing with default ckeditor
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
$contentforedit = '' ;
2018-09-24 15:14:32 +02:00
//$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
//$contentforedit.=$csscontent;
//$contentforedit.='</style>'."\n";
2017-10-07 13:09:31 +02:00
$contentforedit .= $objectpage -> content ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
$contentforedit = preg_replace ( '/(<img.*src=")(?!http)/' , '\1' . DOL_URL_ROOT . '/viewimage.php?modulepart=medias&file=' , $contentforedit , - 1 , $nbrep );
2017-08-21 03:13:44 +02:00
2017-10-07 13:09:31 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$doleditor = new DolEditor ( 'PAGE_CONTENT' , $contentforedit , '' , 500 , 'Full' , '' , true , true , true , ROWS_5 , '90%' );
$doleditor -> Create ( 0 , '' , false );
2018-09-24 15:14:32 +02:00
} */
2016-02-02 16:24:12 +01:00
2018-12-17 17:29:04 +01:00
print " </div> \n " ;
print " </form> \n " ;
2016-04-19 11:02:55 +02:00
2016-02-02 16:24:12 +01:00
2020-04-11 18:18:53 +02:00
if ( $action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction == 'replace' )
2019-08-13 00:34:42 +02:00
{
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-08-13 00:34:42 +02:00
print '<input type="hidden" name="action" value="replacesiteconfirm">' ;
2019-08-13 18:22:18 +02:00
print '<input type="hidden" name="website" value="' . $website -> ref . '">' ;
2019-08-13 00:34:42 +02:00
2020-05-26 22:29:46 +02:00
print '<!-- Search page and replace string -->' . " \n " ;
2019-08-13 00:34:42 +02:00
print '<div class="fiche"><br>' ;
2020-04-11 14:13:16 +02:00
print load_fiche_titre ( $langs -> trans ( " ReplaceWebsiteContent " ), '' , 'search' );
2019-08-13 00:34:42 +02:00
2020-05-26 12:25:41 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2019-08-13 00:34:42 +02:00
print '<div class="tagtable">' ;
print '<div class="tagtr">' ;
2020-05-26 12:25:41 +02:00
print '<div class="tagtd paddingrightonly opacitymedium">' ;
2019-08-13 00:34:42 +02:00
print $langs -> trans ( " SearchReplaceInto " );
print '</div>' ;
print '<div class="tagtd">' ;
2019-11-12 14:07:56 +01:00
print '<input type="checkbox" class="marginleftonly" name="optioncontent" value="content"' . (( ! GETPOSTISSET ( 'buttonreplacesitesearch' ) || GETPOST ( 'optioncontent' , 'aZ09' )) ? ' checked' : '' ) . '> ' . $langs -> trans ( " Content " ) . '<br>' ;
print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"' . ( GETPOST ( 'optionmeta' , 'aZ09' ) ? ' checked' : '' ) . '> ' . $langs -> trans ( " Title " ) . ' | ' . $langs -> trans ( " Description " ) . ' | ' . $langs -> trans ( " Keywords " ) . '<br>' ;
print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"' . ( GETPOST ( 'optionsitefiles' , 'aZ09' ) ? ' checked' : '' ) . '> ' . $langs -> trans ( " GlobalCSSorJS " ) . '<br>' ;
2019-08-13 00:34:42 +02:00
print '</div>' ;
print '</div>' ;
print '<div class="tagtr">' ;
2020-05-26 12:25:41 +02:00
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">' ;
2019-08-13 00:34:42 +02:00
print $langs -> trans ( " SearchString " );
print '</div>' ;
print '<div class="tagtd">' ;
2020-05-04 14:29:25 +02:00
print '<input type="text" name="searchstring" value="' . dol_escape_htmltag ( $searchkey , 0 , 0 , '' , 1 ) . '" autofocus>' ;
2020-05-26 12:25:41 +02:00
print '</div>' ;
print '</div>' ;
2020-05-04 14:29:25 +02:00
2020-05-26 12:25:41 +02:00
print '</div>' ;
2020-04-11 18:18:53 +02:00
2020-05-26 12:25:41 +02:00
print '</div><div class="fichehalfleft">' ;
print '<div class="tagtable">' ;
print '<div class="tagtr">' ;
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">' ;
print $langs -> trans ( " WEBSITE_TYPE_CONTAINER " );
print '</div>' ;
print '<div class="tagtd">' ;
2020-05-26 12:53:58 +02:00
print img_picto ( '' , 'object_technic' , 'class="paddingrightonly"' ) . ' ' ;
$formwebsite -> selectTypeOfContainer ( 'optioncontainertype' , ( GETPOST ( 'optioncontainertype' , 'alpha' ) ? GETPOST ( 'optioncontainertype' , 'alpha' ) : '' ), 1 );
2019-08-13 00:34:42 +02:00
print '</div>' ;
print '</div>' ;
2020-05-26 12:25:41 +02:00
print '<div class="tagtr">' ;
print '<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">' ;
print $langs -> trans ( " Language " );
print '</div>' ;
print '<div class="tagtd">' ;
print img_picto ( '' , 'language' , 'class="paddingrightonly"' ) . ' ' . $formadmin -> select_language ( GETPOSTISSET ( 'optionlanguage' ) ? GETPOST ( 'optionlanguage' ) : '' , 'optionlanguage' , 0 , null , '1' , 0 , 0 , 'minwidth300' , 2 , 0 , 0 , null , 1 );
2019-08-13 00:34:42 +02:00
print '</div>' ;
2020-05-26 12:25:41 +02:00
print '</div>' ;
// Categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
{
print '<div class="tagtr">' ;
print '<div class="tagtd paddingrightonly marginrightonly opacitymedium" style="padding-right: 10px !important">' ;
print $langs -> trans ( " Category " );
print '</div>' ;
print '<div class="tagtd">' ;
print img_picto ( '' , 'category' , 'class="paddingrightonly"' ) . ' ' . $form -> select_all_categories ( Categorie :: TYPE_WEBSITE_PAGE , GETPOSTISSET ( 'optioncategory' ) ? GETPOST ( 'optioncategory' ) : '' , 'optioncategory' , null , null );
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ;
print ajax_combobox ( 'optioncategory' );
print '</div>' ;
print '</div>' ;
}
2019-08-13 00:34:42 +02:00
2020-05-26 12:25:41 +02:00
print '</div>' ;
print '<input type="submit" class="button" name="buttonreplacesitesearch" value="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '">' ;
print '</div></div>' ;
2019-08-13 00:34:42 +02:00
if ( $action == 'replacesiteconfirm' )
{
2020-05-26 12:25:41 +02:00
print '<!-- List of search result -->' . " \n " ;
print '<div class="rowsearchresult clearboth">' ;
2019-08-13 00:34:42 +02:00
print '<br>' ;
print '<br>' ;
if ( $listofpages [ 'code' ] == 'OK' )
{
2020-04-11 18:18:53 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
$param = '' ;
$nbtotalofrecords = count ( $listofpages [ 'list' ]);
2020-05-27 15:36:16 +02:00
$num = $limit ;
2020-04-11 18:18:53 +02:00
$permissiontodelete = 0 ;
// List of mass actions available
2020-04-12 13:25:19 +02:00
$arrayofmassactions = array ();
2020-05-26 12:46:51 +02:00
if ( $user -> rights -> website -> writephp && $searchkey ) $arrayofmassactions [ 'replace' ] = $langs -> trans ( " Replace " );
2020-05-26 22:29:46 +02:00
if ( $user -> rights -> website -> write ) $arrayofmassactions [ 'setcategory' ] = $langs -> trans ( " ClassifyInCategory " );
2020-04-11 18:18:53 +02:00
if ( $permissiontodelete ) $arrayofmassactions [ 'predelete' ] = '<span class="fa fa-trash paddingrightonly"></span>' . $langs -> trans ( " Delete " );
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2020-05-26 12:46:51 +02:00
2020-04-11 18:18:53 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2020-05-26 22:29:46 +02:00
$massactionbutton .= '<div class="massactionother massactionreplace hidden">' ;
2020-04-11 18:18:53 +02:00
$massactionbutton .= $langs -> trans ( " ReplaceString " );
2020-05-26 22:29:46 +02:00
$massactionbutton .= ' <input type="text" name="replacestring" value="' . dol_escape_htmltag ( GETPOST ( 'replacestring' , 'none' )) . '">' ;
$massactionbutton .= '</div>' ;
$massactionbutton .= '<div class="massactionother massactionsetcategory hidden">' ;
$massactionbutton .= $langs -> trans ( " Category " );
$massactionbutton .= ' ' . $form -> select_all_categories ( Categorie :: TYPE_WEBSITE_PAGE , GETPOSTISSET ( 'setcategory' ) ? GETPOST ( 'setcategory' ) : '' , 'setcategory' , 64 , 0 , 0 , 0 , 'minwidth300 alignstart' );
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ;
$massactionbutton .= ajax_combobox ( 'setcategory' );
2020-04-13 13:24:42 +02:00
$massactionbutton .= '</div>' ;
2020-04-11 18:18:53 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
//$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2020-05-26 22:29:46 +02:00
print_barre_liste ( $langs -> trans ( " Results " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'generic' , 0 , '' , '' , $limit , 1 , 1 , 1 );
2020-04-11 18:18:53 +02:00
2020-04-11 14:13:16 +02:00
$param = 'action=replacesiteconfirm&website=' . urlencode ( $website -> ref );
$param .= '&searchstring=' . urlencode ( $searchkey );
if ( GETPOST ( 'optioncontent' )) $param .= '&optioncontent=content' ;
if ( GETPOST ( 'optionmeta' )) $param .= '&optionmeta=meta' ;
if ( GETPOST ( 'optionsitefiles' )) $param .= '&optionsitefiles=optionsitefiles' ;
2020-05-27 15:26:38 +02:00
if ( GETPOST ( 'optioncontainertype' )) $param .= '&optioncontainertype=' . GETPOST ( 'optioncontainertype' , 'aZ09' );
if ( GETPOST ( 'optionlanguage' )) $param .= '&optionlanguage=' . GETPOST ( 'optionlanguage' , 'aZ09' );
if ( GETPOST ( 'optioncategory' )) $param .= '&optioncategory=' . GETPOST ( 'optioncategory' , 'aZ09' );
2020-04-11 14:13:16 +02:00
2019-09-02 18:43:22 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre">' ;
2020-04-11 14:13:16 +02:00
print getTitleFieldOfList ( " Type " , 0 , $_SERVER [ 'PHP_SELF' ], 'type_container' , '' , $param , '' , $sortfield , $sortorder , '' ) . " \n " ;
2020-04-11 16:34:59 +02:00
print getTitleFieldOfList ( " Page " , 0 , $_SERVER [ 'PHP_SELF' ], 'pageurl' , '' , $param , '' , $sortfield , $sortorder , '' ) . " \n " ;
//print getTitleFieldOfList("Description", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n";
2020-04-12 22:54:39 +02:00
print getTitleFieldOfList ( " " , 0 , $_SERVER [ 'PHP_SELF' ]);
2020-05-22 00:38:01 +02:00
print getTitleFieldOfList ( " " , 0 , $_SERVER [ 'PHP_SELF' ]);
2020-04-11 18:18:53 +02:00
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
2019-09-02 18:43:22 +02:00
print '</tr>' ;
2019-11-12 00:15:34 +01:00
foreach ( $listofpages [ 'list' ] as $answerrecord )
2019-08-13 00:34:42 +02:00
{
2019-09-02 18:43:22 +02:00
if ( get_class ( $answerrecord ) == 'WebsitePage' )
{
print '<tr>' ;
2020-04-14 00:03:13 +02:00
2020-04-11 14:13:16 +02:00
print '<td class="nowraponall">' . $langs -> trans ( " Container " ) . ' - ' ;
2020-02-21 17:53:37 +01:00
print $langs -> trans ( $answerrecord -> type_container ); // TODO Use label of container
2019-11-12 14:07:56 +01:00
print '</td>' ;
2020-04-14 00:03:13 +02:00
2019-09-02 18:43:22 +02:00
print '<td>' ;
2019-10-31 21:09:33 +01:00
print $answerrecord -> getNomUrl ( 1 );
print ' <span class="opacitymedium">(' . ( $answerrecord -> title ? $answerrecord -> title : $langs -> trans ( " NoTitle " )) . ')</span>' ;
2020-04-11 16:34:59 +02:00
//print '</td>';
//print '<td class="tdoverflow100">';
print '<br>' ;
print '<span class="opacitymedium">' . $answerrecord -> description . '</span>' ;
2019-09-02 18:43:22 +02:00
print '</td>' ;
2020-04-14 00:03:13 +02:00
2020-05-22 00:38:01 +02:00
$param = '?action=replacesiteconfirm' ;
$param .= '&websiteid=' . $website -> id ;
2020-05-27 15:26:38 +02:00
$param .= '&optioncontent=' . GETPOST ( 'optioncontent' , 'aZ09' );
$param .= '&optionmeta=' . GETPOST ( 'optionmeta' , 'aZ09' );
$param .= '&optionsitefiles=' . GETPOST ( 'optionsitefiles' , 'aZ09' );
$param .= '&optioncontainertype=' . GETPOST ( 'optioncontainertype' , 'aZ09' );
$param .= '&optionlanguage=' . GETPOST ( 'optionlanguage' , 'aZ09' );
$param .= '&optioncategory=' . GETPOST ( 'optioncategory' , 'aZ09' );
$param .= '&searchstring=' . urlencode ( $searchkey );
// Edit properties
print '<td>' ;
2020-05-22 00:38:01 +02:00
$disabled = '' ;
$urltoedithtmlsource = $_SERVER [ " PHP_SELF " ] . '?action=editmeta&websiteid=' . $website -> id . '&pageid=' . $answerrecord -> id . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . $param );
if ( empty ( $user -> rights -> website -> write )) {
$disabled = ' disabled' ;
$urltoedithtmlsource = '' ;
}
print '<a class="editfielda ' . $disabled . '" href="' . $urltoedithtmlsource . '" title="' . $langs -> trans ( " EditPageMeta " ) . '">' . img_picto ( $langs -> trans ( " EditPageMeta " ), 'pencil-ruler' ) . '</a>' ;
print '</td>' ;
// Edit HTML source
2019-12-07 19:08:40 +01:00
print '<td>' ;
$disabled = '' ;
$urltoedithtmlsource = $_SERVER [ " PHP_SELF " ] . '?action=editsource&websiteid=' . $website -> id . '&pageid=' . $answerrecord -> id . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . $param );
if ( empty ( $user -> rights -> website -> write )) {
$disabled = ' disabled' ;
$urltoedithtmlsource = '' ;
}
2020-04-11 14:13:16 +02:00
print '<a class="editfielda ' . $disabled . '" href="' . $urltoedithtmlsource . '" title="' . $langs -> trans ( " EditHTMLSource " ) . '">' . img_picto ( $langs -> trans ( " EditHTMLSource " ), 'edit' ) . '</a>' ;
2019-09-02 18:43:22 +02:00
print '</td>' ;
2020-04-11 18:18:53 +02:00
// Action column
print '<td class="nowrap center">' ;
if ( $massactionbutton || $massaction )
{
$selected = 0 ;
if ( in_array ( $answerrecord -> id , $arrayofselected )) $selected = 1 ;
print '<input id="' . $answerrecord -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $answerrecord -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2019-09-02 18:43:22 +02:00
print '</tr>' ;
}
2020-05-21 09:07:10 +02:00
else {
2019-09-02 18:43:22 +02:00
print '<tr>' ;
2019-11-12 14:07:56 +01:00
2020-04-14 00:03:13 +02:00
print '<td>' ;
2019-11-12 14:07:56 +01:00
$translateofrecordtype = array (
'website_csscontent' => 'WEBSITE_CSS_INLINE' ,
'website_jscontent' => 'WEBSITE_JS_INLINE' ,
'website_robotcontent' => 'WEBSITE_ROBOT' ,
'website_htmlheadercontent' => 'WEBSITE_HTML_HEADER' ,
'website_htaccess' => 'WEBSITE_HTACCESS' ,
'website_readme' => 'WEBSITE_README' ,
'website_manifestjson' => 'WEBSITE_MANIFEST_JSON'
);
2020-02-21 17:53:37 +01:00
if ( ! empty ( $translateofrecordtype [ $answerrecord [ 'type' ]])) {
2019-11-12 14:07:56 +01:00
print $langs -> trans ( $translateofrecordtype [ $answerrecord [ 'type' ]]);
} else {
print $answerrecord [ 'type' ];
}
print '</td>' ;
2020-04-14 00:03:13 +02:00
2020-05-27 15:26:38 +02:00
$param = '?action=replacesiteconfirm' ;
$param .= '&websiteid=' . $website -> id ;
$param .= '&optioncontent=' . GETPOST ( 'optioncontent' , 'aZ09' );
$param .= '&optionmeta=' . GETPOST ( 'optionmeta' , 'aZ09' );
$param .= '&optionsitefiles=' . GETPOST ( 'optionsitefiles' , 'aZ09' );
$param .= '&optioncontainertype=' . GETPOST ( 'optioncontainertype' , 'aZ09' );
$param .= '&optionlanguage=' . GETPOST ( 'optionlanguage' , 'aZ09' );
$param .= '&optioncategory=' . GETPOST ( 'optioncategory' , 'aZ09' );
$param .= '&searchstring=' . urlencode ( $searchkey );
2019-09-02 18:43:22 +02:00
print '<td>' ;
2020-05-27 15:26:38 +02:00
$backtopageurl = $_SERVER [ " PHP_SELF " ] . $param ;
2019-09-02 18:43:22 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editcss&website=' . $website -> ref . '&backtopage=' . urlencode ( $backtopageurl ) . '">' . $langs -> trans ( " EditCss " ) . '</a>' ;
print '</td>' ;
2020-04-14 00:03:13 +02:00
2019-09-02 18:43:22 +02:00
print '<td class="tdoverflow100">' ;
print '</td>' ;
2020-04-11 18:18:53 +02:00
// Action column
print '<td class="nowrap center">' ;
print '</td>' ;
2019-09-02 18:43:22 +02:00
print '</tr>' ;
}
2019-08-13 00:34:42 +02:00
}
2019-09-02 18:43:22 +02:00
print '</table>' ;
2020-05-26 12:25:41 +02:00
print '</div>' ;
2020-04-11 18:18:53 +02:00
print '<br>' ;
2019-08-13 00:34:42 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-08-13 00:34:42 +02:00
print $listofpages [ 'message' ];
}
2020-05-26 12:25:41 +02:00
print '</div>' ;
2019-08-13 00:34:42 +02:00
}
print '</form>' ;
}
2017-08-03 01:45:31 +02:00
if ( $action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' )
2016-04-19 11:02:55 +02:00
{
2018-12-17 19:37:17 +01:00
if ( $pageid > 0 && $atleastonepage )
2017-10-07 13:09:31 +02:00
{
2018-07-24 01:10:38 +02:00
// $filejs
// $filecss
// $filephp
2017-10-07 13:09:31 +02:00
// Ouput page under the Dolibarr top menu
$objectpage -> fetch ( $pageid );
2019-08-14 01:43:06 +02:00
2017-10-07 13:09:31 +02:00
$jscontent = @ file_get_contents ( $filejs );
2016-04-27 09:41:42 +02:00
2018-11-27 16:20:31 +01:00
$out = '<!-- Page content ' . $filetpl . ' : Div with (Htmlheader/Style of page from database + CSS Of website from file + Page content from database or by include if WEBSITE_SUBCONTAINERSINLINE is on) -->' . " \n " ;
2017-07-02 23:38:19 +02:00
2018-07-19 16:06:06 +02:00
// Include a html so we can benefit of the header of page.
// Note: We can't use iframe as it can be used to include another external html file
// Note: We can't use frame as it is deprecated.
2018-09-24 15:14:32 +02:00
/* if ( $includepageintoaframeoradiv == 'iframe' )
{
$out .= " <iframe><body></html> " ;
} */
2019-11-12 00:15:34 +01:00
$out .= " \n <html><head> \n " ;
$out .= " <!-- htmlheader/style of page from database --> \n " ;
$out .= dolWebsiteReplacementOfLinks ( $object , $objectpage -> htmlheader , 1 , 'htmlheader' );
2019-08-14 01:43:06 +02:00
2019-11-12 00:15:34 +01:00
$out .= " <!-- htmlheader/style of website from files --> \n " ;
2019-08-14 01:43:06 +02:00
// TODO Keep only the <link> or the <script> tags
/*
$htmlheadercontent = @ file_get_contents ( $filehtmlheader );
$dom = new DOMDocument ;
@ $dom -> loadHTML ( $htmlheadercontent );
$styles = $dom -> getElementsByTagName ( 'link' );
$scripts = $dom -> getElementsByTagName ( 'script' );
foreach ( $styles as $stylescursor )
{
$out .= $stylescursor ;
}
foreach ( $scripts as $scriptscursor )
{
$out .= $scriptscursor ;
}
*/
2019-11-12 00:15:34 +01:00
$out .= " </head> \n " ;
$out .= " \n <body> " ;
2018-07-19 16:06:06 +02:00
2018-09-24 15:14:32 +02:00
2019-11-12 00:15:34 +01:00
$out .= '<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">' . " \n " ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
// REPLACEMENT OF LINKS When page called by website editor
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
$out .= '<!-- style of website from file -->' . " \n " ;
$out .= '<style scoped>' . " \n " ; // "scoped" means "apply to parent element only". No more supported by browsers, snif !
$tmpout = '' ;
$tmpout .= '/* Include website CSS file */' . " \n " ;
2018-07-23 14:08:20 +02:00
//$csscontent = @file_get_contents($filecss);
ob_start ();
include $filecss ;
$csscontent = ob_get_contents ();
ob_end_clean ();
2019-11-12 00:15:34 +01:00
$tmpout .= dolWebsiteReplacementOfLinks ( $object , $csscontent , 1 , 'css' );
$tmpout .= '/* Include style from the HTML header of page */' . " \n " ;
2017-12-17 16:24:47 +01:00
// Clean the html header of page to get only <style> content
$tmp = preg_split ( '(<style[^>]*>|</style>)' , $objectpage -> htmlheader );
2019-11-12 00:15:34 +01:00
$tmpstyleinheader = '' ;
$i = 0 ;
foreach ( $tmp as $valtmp )
2017-12-17 16:24:47 +01:00
{
$i ++ ;
2019-11-12 00:15:34 +01:00
if ( $i % 2 == 0 ) $tmpstyleinheader .= $valtmp . " \n " ;
2017-12-17 16:24:47 +01:00
}
2019-11-12 00:15:34 +01:00
$tmpout .= $tmpstyleinheader . " \n " ;
2017-12-17 16:24:47 +01:00
// Clean style that may affect global style of Dolibarr
2019-11-12 00:15:34 +01:00
$tmpout = preg_replace ( '/}[\s\n]*body\s*{[^}]+}/ims' , '}' , $tmpout );
$out .= $tmpout ;
$out .= '</style>' . " \n " ;
2017-07-02 23:38:19 +02:00
2018-07-19 21:35:21 +02:00
// Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor
2017-12-12 03:10:54 +01:00
// Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders,
2018-07-19 16:06:06 +02:00
// so editable will be available only from container created from scratch
2018-09-25 16:35:59 +02:00
//$out.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n";
2019-11-12 00:15:34 +01:00
$out .= '<div id="divbodywebsite" class="bodywebsite bodywebpage-' . $objectpage -> ref . '">' . " \n " ;
2017-07-21 02:30:02 +02:00
2018-07-19 21:35:21 +02:00
$newcontent = $objectpage -> content ;
2018-09-24 15:14:32 +02:00
// If mode WEBSITE_SUBCONTAINERSINLINE is on
2019-11-12 00:15:34 +01:00
if ( ! empty ( $conf -> global -> WEBSITE_SUBCONTAINERSINLINE ))
2018-09-24 15:14:32 +02:00
{
2020-03-20 16:30:45 +01:00
// TODO Check file $filephp exists, if not create it.
2018-09-24 15:14:32 +02:00
//var_dump($filetpl);
$filephp = $filetpl ;
ob_start ();
2020-03-20 16:30:45 +01:00
try {
$res = include $filephp ;
if ( empty ( $res )) {
print " ERROR: Failed to include file ' " . $filephp . " '. Try to edit and save page. " ;
}
2020-04-10 10:59:32 +02:00
} catch ( Exception $e )
2020-03-20 16:30:45 +01:00
{
print $e -> getMessage ();
}
2018-09-24 15:14:32 +02:00
$newcontent = ob_get_contents ();
ob_end_clean ();
}
// Change the contenteditable to "true" or "false" when mode Edit Inline is on or off
2018-07-20 15:01:50 +02:00
if ( empty ( $conf -> global -> WEBSITE_EDITINLINE ))
2018-07-19 21:35:21 +02:00
{
2019-04-12 17:44:22 +02:00
// Remove the contenteditable="true"
2018-07-20 15:01:50 +02:00
$newcontent = preg_replace ( '/(div|section)(\s[^\>]*)contenteditable="true"/' , '\1\2' , $newcontent );
2018-07-19 21:35:21 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2019-04-12 17:44:22 +02:00
// Keep the contenteditable="true" when mode Edit Inline is on
2018-07-19 21:35:21 +02:00
}
2019-11-12 00:15:34 +01:00
$out .= dolWebsiteReplacementOfLinks ( $object , $newcontent , 0 , 'html' , $objectpage -> id ) . " \n " ;
2018-11-27 16:20:31 +01:00
//$out.=$newcontent;
2017-07-02 23:38:19 +02:00
2019-11-12 00:15:34 +01:00
$out .= '</div>' ;
2017-07-28 17:17:40 +02:00
2019-11-12 00:15:34 +01:00
$out .= '</div> <!-- End div id=websitecontentundertopmenu -->' ;
2017-07-02 23:38:19 +02:00
2018-07-19 16:06:06 +02:00
/* if ( $includepageintoaframeoradiv == 'iframe' )
{
$out .= " </body></html></iframe> " ;
} */
$out .= " \n </body></html> \n " ;
2019-11-12 00:15:34 +01:00
$out .= " \n " . '<!-- End page content ' . $filetpl . ' -->' . " \n \n " ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
print $out ;
2017-07-02 23:38:19 +02:00
2017-10-07 13:09:31 +02:00
/* file_put_contents ( $filetpl , $out );
2016-05-01 16:34:50 +02:00
if ( ! empty ( $conf -> global -> MAIN_UMASK ))
@ chmod ( $filetpl , octdec ( $conf -> global -> MAIN_UMASK ));
// Output file on browser
dol_syslog ( " index.php include $filetpl $filename content-type= $type " );
$original_file_osencoded = dol_osencode ( $filetpl ); // New file name encoded in OS encoding charset
2017-07-02 23:38:19 +02:00
2016-05-01 16:34:50 +02:00
// This test if file exists should be useless. We keep it to find bug more easily
if ( ! file_exists ( $original_file_osencoded ))
{
dol_print_error ( 0 , $langs -> trans ( " ErrorFileDoesNotExists " , $original_file ));
exit ;
}
2017-07-02 23:38:19 +02:00
2016-05-01 16:34:50 +02:00
//include_once $original_file_osencoded;
*/
2017-07-02 23:38:19 +02:00
2018-07-22 17:18:35 +02:00
/* print '<iframe class="websiteiframenoborder centpercent" src="' . DOL_URL_ROOT . '/public/website/index.php?website=' . $websitekey . '&pageid=' . $pageid . '"/>' ;
2016-05-01 16:34:50 +02:00
print '</iframe>' ; */
2017-10-07 13:09:31 +02:00
}
2020-05-21 09:07:10 +02:00
else {
2018-12-17 17:29:04 +01:00
if ( empty ( $websitekey ) || $websitekey == '-1' )
{
2019-10-09 15:01:19 +02:00
print '<br><br><div class="center previewnotyetavailable"><span class="">' . $langs -> trans ( " NoWebSiteCreateOneFirst " ) . '</span></div><br><br><br>' ;
2018-12-17 17:29:04 +01:00
print '<div class="center"><div class="logo_setup"></div></div>' ;
}
2020-05-21 09:07:10 +02:00
else {
2019-10-09 15:01:19 +02:00
print '<br><br><div class="center previewnotyetavailable"><span class="">' . $langs -> trans ( " PreviewOfSiteNotYetAvailable " , $object -> ref ) . '</span></div><br><br><br>' ;
2018-12-17 17:29:04 +01:00
print '<div class="center"><div class="logo_setup"></div></div>' ;
}
2017-10-07 13:09:31 +02:00
}
2016-04-19 11:02:55 +02:00
}
2018-08-04 15:58:05 +02:00
// End of page
2016-02-02 16:24:12 +01:00
llxFooter ();
$db -> close ();