Merge branch 'develop' into fix-rest-api-supplierinvoices-post-with-lines-fk_product
This commit is contained in:
commit
0672f3806e
@ -458,16 +458,6 @@ variables_order = "GPCS"
|
||||
; with user data. This makes most sense when coupled with track_vars - in which
|
||||
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
|
||||
; variables.
|
||||
;
|
||||
; You should do your best to write your scripts so that they do not require
|
||||
; register_globals to be on; Using form variables as globals can easily lead
|
||||
; to possible security problems, if the code is not very well thought of.
|
||||
register_globals = Off
|
||||
|
||||
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
|
||||
; and friends. If you're not using them, it's recommended to turn them off,
|
||||
; for performance reasons.
|
||||
register_long_arrays = Off
|
||||
|
||||
; This directive tells PHP whether to declare the argv&argc variables (that
|
||||
; would contain the GET information). If you don't use these variables, you
|
||||
@ -477,8 +467,7 @@ register_argc_argv = Off
|
||||
; When enabled, the SERVER and ENV variables are created when they're first
|
||||
; used (Just In Time) instead of when the script starts. If these variables
|
||||
; are not used within a script, having this directive on will result in a
|
||||
; performance gain. The PHP directives register_globals, register_long_arrays,
|
||||
; and register_argc_argv must be disabled for this directive to have any affect.
|
||||
; performance gain.
|
||||
auto_globals_jit = On
|
||||
|
||||
; Maximum size of POST data that PHP will accept.
|
||||
@ -1101,14 +1090,6 @@ session.gc_maxlifetime = 1800
|
||||
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
|
||||
; cd /path/to/sessions; find -cmin +24 | xargs rm
|
||||
|
||||
; PHP 4.2 and less have an undocumented feature/bug that allows you to
|
||||
; to initialize a session variable in the global scope, albeit register_globals
|
||||
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
|
||||
; You can disable the feature and the warning separately. At this time,
|
||||
; the warning is only displayed, if bug_compat_42 is enabled.
|
||||
|
||||
session.bug_compat_42 = 0
|
||||
session.bug_compat_warn = 1
|
||||
|
||||
; Check HTTP Referer to invalidate externally stored URLs containing ids.
|
||||
; HTTP_REFERER has to contain this substring for the session to be
|
||||
|
||||
@ -29,16 +29,6 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
|
||||
ErrorDocument 401 /public/error-401.php
|
||||
ErrorDocument 404 /public/error-404.php
|
||||
|
||||
<IfModule mod_php4.c>
|
||||
php_flag magic_quotes_gpc Off
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_php5.c>
|
||||
php_flag magic_quotes_gpc Off
|
||||
php_flag register_globals Off
|
||||
</IfModule>
|
||||
|
||||
|
||||
# OPTIMIZE: To use gzip compressed files (for Dolibarr already compressed files).
|
||||
# Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set.
|
||||
|
||||
@ -658,20 +658,6 @@ html_errors = Off
|
||||
; Example:
|
||||
;arg_separator.input = ";&"
|
||||
|
||||
; This directive determines which super global arrays are registered when PHP
|
||||
; starts up. If the register_globals directive is enabled, it also determines
|
||||
; what order variables are populated into the global space. G,P,C,E & S are
|
||||
; abbreviations for the following respective super globals: GET, POST, COOKIE,
|
||||
; ENV and SERVER. There is a performance penalty paid for the registration of
|
||||
; these arrays and because ENV is not as commonly used as the others, ENV is
|
||||
; is not recommended on productions servers. You can still get access to
|
||||
; the environment variables through getenv() should you need to.
|
||||
; Default Value: "EGPCS"
|
||||
; Development Value: "GPCS"
|
||||
; Production Value: "GPCS";
|
||||
; http://php.net/variables-order
|
||||
variables_order = "GPCS"
|
||||
|
||||
; This directive determines which super global data (G,P,C,E & S) should
|
||||
; be registered into the super global array REQUEST. If so, it also determines
|
||||
; the order in which that data is registered. The values for this directive are
|
||||
@ -685,15 +671,6 @@ variables_order = "GPCS"
|
||||
; http://php.net/request-order
|
||||
request_order = "GP"
|
||||
|
||||
; Whether or not to register the EGPCS variables as global variables. You may
|
||||
; want to turn this off if you don't want to clutter your scripts' global scope
|
||||
; with user data.
|
||||
; You should do your best to write your scripts so that they do not require
|
||||
; register_globals to be on; Using form variables as globals can easily lead
|
||||
; to possible security problems, if the code is not very well thought of.
|
||||
; http://php.net/register-globals
|
||||
register_globals = Off
|
||||
|
||||
; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
|
||||
; are registered by PHP or not. As they are deprecated, we obviously don't
|
||||
; recommend you use them. They are on by default for compatibility reasons but
|
||||
@ -722,8 +699,7 @@ register_argc_argv = Off
|
||||
; When enabled, the SERVER and ENV variables are created when they're first
|
||||
; used (Just In Time) instead of when the script starts. If these variables
|
||||
; are not used within a script, having this directive on will result in a
|
||||
; performance gain. The PHP directives register_globals, register_long_arrays,
|
||||
; and register_argc_argv must be disabled for this directive to have any affect.
|
||||
; performance gain.
|
||||
; http://php.net/auto-globals-jit
|
||||
auto_globals_jit = On
|
||||
|
||||
@ -1516,22 +1492,6 @@ session.gc_maxlifetime = 1440
|
||||
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
|
||||
; find /path/to/sessions -cmin +24 | xargs rm
|
||||
|
||||
; PHP 4.2 and less have an undocumented feature/bug that allows you to
|
||||
; to initialize a session variable in the global scope, even when register_globals
|
||||
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
|
||||
; You can disable the feature and the warning separately. At this time,
|
||||
; the warning is only displayed, if bug_compat_42 is enabled. This feature
|
||||
; introduces some serious security problems if not handled correctly. It's
|
||||
; recommended that you do not use this feature on production servers. But you
|
||||
; should enable this on development servers and enable the warning as well. If you
|
||||
; do not enable the feature on development servers, you won't be warned when it's
|
||||
; used and debugging errors caused by this can be difficult to track down.
|
||||
; Default Value: On
|
||||
; Development Value: On
|
||||
; Production Value: Off
|
||||
; http://php.net/session.bug-compat-42
|
||||
session.bug_compat_42 = Off
|
||||
|
||||
; This setting controls whether or not you are warned by PHP when initializing a
|
||||
; session value into the global space. session.bug_compat_42 must be enabled before
|
||||
; these warnings can be issued by PHP. See the directive above for more information.
|
||||
|
||||
3886
htdocs/core/class/lessc.class.php
Normal file
3886
htdocs/core/class/lessc.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -856,7 +856,8 @@ function newpopup(url, title) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function show document preview. Use the "dialog" function.
|
||||
* Function show document preview. It uses the "dialog" function.
|
||||
* The a tag around the img must have the src='', class='documentpreview', mime='image/xxx', target='_blank' from getAdvancedPreviewUrl().
|
||||
*
|
||||
* @param string file Url
|
||||
* @param string type Mime file type ("image/jpeg", "application/pdf", "text/html")
|
||||
|
||||
@ -1889,24 +1889,87 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = ''
|
||||
*/
|
||||
function dol_compress_file($inputfile, $outputfile, $mode = "gz")
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$foundhandler=0;
|
||||
|
||||
try
|
||||
{
|
||||
dol_syslog("dol_compress_file mode=".$mode." inputfile=".$inputfile." outputfile=".$outputfile);
|
||||
|
||||
$data = implode("", file(dol_osencode($inputfile)));
|
||||
if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); }
|
||||
elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); }
|
||||
elseif ($mode == 'zip')
|
||||
{
|
||||
if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS))
|
||||
{
|
||||
$foundhandler=1;
|
||||
|
||||
$rootPath = realpath($inputfile);
|
||||
|
||||
dol_syslog("Class ZipArchive is set so we zip using ZipArchive to zip into ".$outputfile.' rootPath='.$rootPath);
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open($outputfile, ZipArchive::CREATE)!==TRUE) {
|
||||
$errormsg="Failed to open file ".$outputfile."\n";
|
||||
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR);
|
||||
return -6;
|
||||
}
|
||||
|
||||
// Create recursive directory iterator
|
||||
/** @var SplFileInfo[] $files */
|
||||
$files = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($rootPath),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($files as $name => $file)
|
||||
{
|
||||
// Skip directories (they would be added automatically)
|
||||
if (!$file->isDir())
|
||||
{
|
||||
// Get real and relative path for current file
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen($rootPath) + 1);
|
||||
|
||||
// Add current file to archive
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Zip archive will be created only after closing object
|
||||
$zip->close();
|
||||
|
||||
dol_syslog("dol_compress_file success - ".count($zip->numFiles)." files");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (defined('ODTPHP_PATHTOPCLZIP'))
|
||||
{
|
||||
$foundhandler=1;
|
||||
|
||||
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||
$archive = new PclZip($outputfile);
|
||||
$archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
|
||||
//$archive->add($inputfile);
|
||||
return 1;
|
||||
$result = $archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
|
||||
|
||||
if ($result === 0)
|
||||
{
|
||||
global $errormsg;
|
||||
$errormsg=$archive->errorInfo(true);
|
||||
dol_syslog("dol_compress_file failure - ".$errormsg, LOG_ERR);
|
||||
if ($archive->errorCode() == PCLZIP_ERR_WRITE_OPEN_FAIL)
|
||||
{
|
||||
dol_syslog("dol_compress_file error PCLZIP_ERR_WRITE_OPEN_FAIL", LOG_ERR);
|
||||
return -4;
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("dol_compress_file success - ".count($result)." files");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1942,9 +2005,9 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz")
|
||||
*/
|
||||
function dol_uncompress($inputfile, $outputdir)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
if (defined('ODTPHP_PATHTOPCLZIP'))
|
||||
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS))
|
||||
{
|
||||
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
||||
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||
|
||||
@ -23,21 +23,23 @@
|
||||
|
||||
|
||||
/**
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
|
||||
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content. It replaces also dynamic content with '...php...'
|
||||
* Used to ouput the page on the Preview from backoffice.
|
||||
*
|
||||
* @param Website $website Web site object
|
||||
* @param string $content Content to replace
|
||||
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
|
||||
* @param string $contenttype Content type
|
||||
* @param int $containerid Contenair id
|
||||
* @return boolean True if OK
|
||||
* @see dolWebsiteOutput() for function used to replace content in a web server context
|
||||
*/
|
||||
function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html')
|
||||
function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype='html', $containerid='')
|
||||
{
|
||||
$nbrep = 0;
|
||||
|
||||
dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')', LOG_DEBUG);
|
||||
dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'').')', LOG_DEBUG);
|
||||
//if ($contenttype == 'html') { print $content;exit; }
|
||||
|
||||
// Replace php code. Note $content may come from database and does not contains body tags.
|
||||
$replacewith='...php...';
|
||||
@ -61,7 +63,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
$content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
|
||||
|
||||
//$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='<span class="phptag">...php...</span>';
|
||||
$replacewith='...phpx...';
|
||||
if ($removephppart) $replacewith='';
|
||||
//$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content);
|
||||
/*if ($content === null) {
|
||||
@ -72,8 +74,9 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
|
||||
// Replace relative link / with dolibarr URL
|
||||
$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
|
||||
// Replace relative link /xxx.php with dolibarr URL
|
||||
$content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
|
||||
// Replace relative link /xxx.php#aaa or /xxx.php with dolibarr URL (we discard param ?...)
|
||||
// TODO To support replacement of /xxx.php?bbb=ccc we must be able to replace only if link is not already DOL_URL_ROOT.'/website/index.php
|
||||
$content = preg_replace('/(href=")\/?([^:\"]*)\.php(\?[^\"<>#]*)?(#[^\"<>]*)?\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2\4"', $content, -1, $nbrep);
|
||||
|
||||
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
|
||||
$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
@ -93,7 +96,11 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
|
||||
$content=preg_replace('/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
dol_syslog('dolWebsiteReplacementOfLinks end', LOG_DEBUG);
|
||||
//if ($contenttype == 'html') { print $content;exit; }
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -124,14 +131,15 @@ function dolStripPhpCode($str, $replacewith = '')
|
||||
$newstr .= $part;
|
||||
continue;
|
||||
}
|
||||
//split on closing tag
|
||||
// The second part is the php code. We split on closing tag
|
||||
$partlings = explode('?>', $part);
|
||||
if (!empty($partlings))
|
||||
{
|
||||
$phppart = $partlings[0];
|
||||
//remove content before closing tag
|
||||
if (count($partlings) > 1) $partlings[0] = '';
|
||||
if (count($partlings) > 1) $partlings[0] = ''; // Todo why a count > 1 and not >= 1 ?
|
||||
//append to out string
|
||||
$newstr .= $replacewith.implode('', $partlings);
|
||||
$newstr .= '<span class="phptag">'.$replacewith.'<!-- '.$phppart.' --></span>'.implode('', $partlings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,14 +193,14 @@ function dolKeepOnlyPhpCode($str)
|
||||
* @param string $contenttype Content type
|
||||
* @param int $containerid Contenair id
|
||||
* @return void
|
||||
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
|
||||
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context.
|
||||
*/
|
||||
function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
global $dolibarr_main_url_root, $dolibarr_main_data_root;
|
||||
|
||||
dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
|
||||
dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'').')');
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
@ -228,6 +236,7 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
|
||||
$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
|
||||
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
|
||||
$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
|
||||
@ -214,13 +214,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,13 +235,7 @@ function dolSaveCssFile($filecss, $csscontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,13 +256,7 @@ function dolSaveJsFile($filejs, $jscontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filejs, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,13 +277,7 @@ function dolSaveRobotFile($filerobot, $robotcontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,13 +298,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,19 +319,33 @@ function dolSaveManifestJson($file, $content)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$file, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return true;
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $file Full path of filename to generate
|
||||
* @param string $content Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveReadme($file, $content)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save README.md file into ".$file);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($file, $content);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show list of themes. Show all thumbs of themes
|
||||
* Show list of themes. Show all thumbs of themes/skins
|
||||
*
|
||||
* @param Website $website Object website to load the tempalte into
|
||||
* @return void
|
||||
@ -433,11 +417,25 @@ function showWebsiteTemplates(Website $website)
|
||||
|
||||
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
|
||||
|
||||
$file=$dirtheme."/".$subdirwithoutzip.".jpg";
|
||||
$file = $dirtheme."/".$subdirwithoutzip.".jpg";
|
||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
|
||||
|
||||
if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
|
||||
|
||||
$originalfile = basename($file);
|
||||
$entity = $conf->entity;
|
||||
$modulepart = 'doctemplateswebsite';
|
||||
$cache = '';
|
||||
$title = $file;
|
||||
|
||||
$ret='';
|
||||
$urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
|
||||
if (! empty($urladvanced)) $ret.='<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
|
||||
else $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
|
||||
print $ret;
|
||||
print '<img class="websiteskinthumb shadow" src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
|
||||
print '</a>';
|
||||
|
||||
print '<br>';
|
||||
print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')';
|
||||
print '<br><a href="'.$_SERVER["PHP_SELF"].'?action=importsiteconfirm&website='.$website->ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").'</a>';
|
||||
|
||||
@ -158,7 +158,7 @@ class modWebsite extends DolibarrModules
|
||||
// Remove permissions and default values
|
||||
$this->remove($options);
|
||||
|
||||
// Copy flags and octicons directoru
|
||||
// Copy flags and octicons directory
|
||||
$dirarray=array('common/flags', 'common/octicons');
|
||||
foreach($dirarray as $dir)
|
||||
{
|
||||
@ -179,6 +179,26 @@ class modWebsite extends DolibarrModules
|
||||
}
|
||||
}
|
||||
|
||||
// Website templates
|
||||
$srcroot=DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';
|
||||
$destroot=DOL_DATA_ROOT.'/doctemplates/websites';
|
||||
|
||||
dol_mkdir($destroot);
|
||||
|
||||
$docs=dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$');
|
||||
foreach($docs as $cursorfile)
|
||||
{
|
||||
$src=$srcroot.'/'.$cursorfile['name'];
|
||||
$dest=$destroot.'/'.$cursorfile['name'];
|
||||
|
||||
$result=dol_copy($src, $dest, 0, 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
|
||||
@ -80,7 +80,7 @@ class Interventions extends DolibarrApi
|
||||
|
||||
$result = $this->fichinter->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Intervention report not found');
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
@ -174,10 +174,10 @@ class Interventions extends DolibarrApi
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve fichinter list : '.$db->lasterror());
|
||||
throw new RestException(503, 'Error when retrieve intervention list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No finchinter found');
|
||||
throw new RestException(404, 'No intervention found');
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
@ -200,7 +200,7 @@ class Interventions extends DolibarrApi
|
||||
}
|
||||
|
||||
if ($this->fichinter->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating fichinter", array_merge(array($this->fichinter->error), $this->fichinter->errors));
|
||||
throw new RestException(500, "Error creating intervention", array_merge(array($this->fichinter->error), $this->fichinter->errors));
|
||||
}
|
||||
|
||||
return $this->fichinter->id;
|
||||
@ -301,7 +301,7 @@ class Interventions extends DolibarrApi
|
||||
throw new RestException(404, 'Intervention not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) {
|
||||
if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
Binary file not shown.
@ -15,6 +15,8 @@ WEBSITE_HTML_HEADER=Addition at bottom of HTML Header (common to all pages)
|
||||
WEBSITE_ROBOT=Robot file (robots.txt)
|
||||
WEBSITE_HTACCESS=Website .htaccess file
|
||||
WEBSITE_MANIFEST_JSON=Website manifest.json file
|
||||
WEBSITE_README=README.md file
|
||||
EnterHereLicenseInformation=Enter here meta data or license information to fille a README.md file. if you distribute your website as a template, the file will be included into the temptate package.
|
||||
HtmlHeaderPage=HTML header (specific to this page only)
|
||||
PageNameAliasHelp=Name or alias of the page.<br>This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "<strong>%s</strong>" to edit this alias.
|
||||
EditTheWebSiteForACommonHeader=Note: If you want to define a personalized header for all pages, edit the header on the site level instead of on the page/container.
|
||||
@ -106,4 +108,6 @@ DeleteAlsoJs=Delete also all javascript files specific to this website?
|
||||
DeleteAlsoMedias=Delete also all medias files specific to this website?
|
||||
MyWebsitePages=My website pages
|
||||
SearchReplaceInto=Search | Replace into
|
||||
ReplaceString=New string
|
||||
ReplaceString=New string
|
||||
CSSContentTooltipHelp=Enter here CSS content. To avoid any conflict with the CSS of the application, be sure to prepend all declaration with the .bodywebsite class. For example:<br><br>#mycssselector, input.myclass:hover { ... }<br>must be<br>.bodywebsite #mycssselector, .bodywebsite input.myclass:hover { ... }<br><br>Note: If you have a large file without this prefix, you can use 'lessc' to convert it to append the .bodywebsite prefix everywhere.
|
||||
LinkAndScriptsHereAreNotLoadedInEditor=Warning: This content is output only when site is accessed from a server. It is not used in Edit mode so if you need to load javascript files also in edit mode, just add your tag 'script src=...' into the page.
|
||||
@ -624,7 +624,7 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
|
||||
session_start(); // Fixing the bug of register_globals here is useless since session is empty
|
||||
session_start();
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
@ -681,7 +681,7 @@ if (! defined('NOLOGIN'))
|
||||
session_destroy();
|
||||
session_name($sessionname);
|
||||
session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
|
||||
session_start(); // Fixing the bug of register_globals here is useless since session is empty
|
||||
session_start();
|
||||
|
||||
if ($resultFetchUser == 0)
|
||||
{
|
||||
@ -1441,6 +1441,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
|
||||
print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
|
||||
print '</script>'."\n";
|
||||
print '<script src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
|
||||
print '<script>';
|
||||
print 'CKEDITOR.disableAutoInline = true;'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
// Browser notifications
|
||||
|
||||
@ -245,3 +245,4 @@ $hookmanager=new HookManager($db);
|
||||
|
||||
|
||||
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR', 'NPR');
|
||||
//if (! defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $conf->user->dir_temp);
|
||||
|
||||
@ -3020,11 +3020,15 @@ table.noborder.paymenttable {
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
/* Disable shadows */
|
||||
/* Disable-Enable shadows */
|
||||
.noshadow {
|
||||
-webkit-box-shadow: 0px 0px 0px #DDD !important;
|
||||
box-shadow: 0px 0px 0px #DDD !important;
|
||||
}
|
||||
.shadow {
|
||||
-webkit-box-shadow: 2px 2px 5px #CCC !important;
|
||||
box-shadow: 2px 2px 5px #CCC !important;
|
||||
}
|
||||
|
||||
div.tabBar .noborder {
|
||||
-webkit-box-shadow: 0px 0px 0px #DDD !important;
|
||||
|
||||
@ -790,7 +790,7 @@ class Website extends CommonObject
|
||||
/**
|
||||
* Generate a zip with all data of web site.
|
||||
*
|
||||
* @return string Path to file with zip
|
||||
* @return string Path to file with zip or '' if error
|
||||
*/
|
||||
public function exportWebSite()
|
||||
{
|
||||
@ -931,6 +931,10 @@ class Website extends CommonObject
|
||||
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport);
|
||||
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport);
|
||||
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport);
|
||||
|
||||
// When we have a link src="image/websiteref/file.png" into html content
|
||||
$stringtoexport = str_replace('="image/'.$website->ref.'/', '="image/__WEBSITE_KEY__/', $stringtoexport);
|
||||
|
||||
$line.= "'".$this->db->escape($stringtoexport)."'"; // Replace \r \n to have record on 1 line
|
||||
$line.= ");";
|
||||
$line.= "\n";
|
||||
@ -957,9 +961,18 @@ class Website extends CommonObject
|
||||
$filename = $conf->website->dir_temp.'/'.$website->ref.'/website_'.$website->ref.'-'.dol_print_date(dol_now(), 'dayhourlog').'.zip';
|
||||
|
||||
dol_delete_file($fileglob, 0);
|
||||
dol_compress_file($filedir, $filename, 'zip');
|
||||
$result = dol_compress_file($filedir, $filename, 'zip');
|
||||
|
||||
return $filename;
|
||||
if ($result > 0)
|
||||
{
|
||||
return $filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $errormsg;
|
||||
$this->error = $errormsg;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -184,6 +184,7 @@ $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||
$fileindex=$pathofwebsite.'/index.php';
|
||||
$filewrapper=$pathofwebsite.'/wrapper.php';
|
||||
$filemanifestjson=$pathofwebsite.'/manifest.json.php';
|
||||
$filereadme=$pathofwebsite.'/README.md';
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
@ -338,7 +339,7 @@ if ($action == 'addsite')
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha')))
|
||||
if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha')))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors');
|
||||
@ -414,6 +415,7 @@ if ($action == 'addcontainer')
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
|
||||
//if (! preg_match('/^http/', $urltograb) && ! preg_match('/^file/', $urltograb))
|
||||
if (! preg_match('/^http/', $urltograb))
|
||||
{
|
||||
$error++;
|
||||
@ -427,6 +429,7 @@ if ($action == 'addcontainer')
|
||||
// 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);
|
||||
//$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb);
|
||||
$urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam);
|
||||
if (empty($urltograbwithoutdomainandparam) && ! preg_match('/\/$/', $urltograb))
|
||||
{
|
||||
@ -770,7 +773,10 @@ if ($action == 'addcontainer')
|
||||
|
||||
// Save page alias
|
||||
$result=dolSavePageAlias($filealias, $object, $objectpage);
|
||||
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
}
|
||||
|
||||
// Save page of content
|
||||
$result=dolSavePageContent($filetpl, $object, $objectpage);
|
||||
@ -850,6 +856,11 @@ if ($action == 'addcontainer')
|
||||
$result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent);
|
||||
}
|
||||
|
||||
if (! dol_is_file($filereadme))
|
||||
{
|
||||
$readmecontent = "Website generated by Dolibarr ERP CRM";
|
||||
$result=dolSaveReadme($filereadme, $readmecontent);
|
||||
}
|
||||
|
||||
$action = 'preview';
|
||||
}
|
||||
@ -988,7 +999,11 @@ if ($action == 'updatecss')
|
||||
|
||||
// Now generate the master.inc.php page
|
||||
$result = dolSaveMasterFile($filemaster);
|
||||
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemaster, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Html header file
|
||||
@ -1012,7 +1027,12 @@ if ($action == 'updatecss')
|
||||
|
||||
$htmlheadercontent = trim($htmlheadercontent)."\n";
|
||||
|
||||
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
$result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Css file
|
||||
@ -1024,23 +1044,21 @@ if ($action == 'updatecss')
|
||||
$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.= GETPOST('WEBSITE_CSS_INLINE', 'none');
|
||||
$csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n";
|
||||
|
||||
$csscontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$csscontent.= '<?php // BEGIN PHP'."\n";
|
||||
$csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n";
|
||||
$csscontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save css content into ".$filecss);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filecss, $csscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveCssFile($filecss, $csscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1061,19 +1079,13 @@ if ($action == 'updatecss')
|
||||
$jscontent.= "header('Content-type: application/javascript');\n";
|
||||
$jscontent.= "// END PHP ?>\n";
|
||||
|
||||
$jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none');
|
||||
$jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n";
|
||||
|
||||
$jscontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$jscontent.= '<?php // BEGIN PHP'."\n";
|
||||
$jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n";
|
||||
$jscontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save js content into ".$filejs);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filejs, $jscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveJsFile($filejs, $jscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1094,19 +1106,13 @@ if ($action == 'updatecss')
|
||||
$robotcontent.= "header('Content-type: text/css');\n";
|
||||
$robotcontent.= "// END PHP ?>\n";*/
|
||||
|
||||
$robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
|
||||
$robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n";
|
||||
|
||||
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n";
|
||||
$robotcontent.= "// END PHP ?>"."\n";*/
|
||||
|
||||
dol_syslog("Save file robot into ".$filerobot);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filerobot, $robotcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$result = dolSaveRobotFile($filerobot, $robotcontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
@ -1116,20 +1122,15 @@ if ($action == 'updatecss')
|
||||
|
||||
// Htaccess file
|
||||
$htaccesscontent ='';
|
||||
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
|
||||
$htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n";
|
||||
|
||||
dol_syslog("Save file htaccess into ".$filehtaccess);
|
||||
$result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
}
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtaccess, $htaccesscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
}
|
||||
|
||||
// manifest.json file
|
||||
$manifestjsoncontent ='';
|
||||
@ -1144,24 +1145,45 @@ if ($action == 'updatecss')
|
||||
$manifestjsoncontent.= "header('Content-type: application/manifest+json');\n";
|
||||
$manifestjsoncontent.= "// END PHP ?>\n";
|
||||
|
||||
$manifestjsoncontent.= GETPOST('WEBSITE_MANIFEST_JSON', 'none');
|
||||
$manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n";
|
||||
|
||||
$manifestjsoncontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$manifestjsoncontent.= '<?php // BEGIN PHP'."\n";
|
||||
$manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
|
||||
$manifestjsoncontent.= "// END PHP ?>"."\n";
|
||||
|
||||
dol_syslog("Save file manifest.json.php into ".$manifestjsoncontent);
|
||||
$result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
|
||||
}
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filemanifestjson, $manifestjsoncontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filemanifestjson, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if ($result === false)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
|
||||
}
|
||||
// README.md file
|
||||
$readmecontent ='';
|
||||
|
||||
/*$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";*/
|
||||
|
||||
$readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n";
|
||||
|
||||
/*$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);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filereadme, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Message if no error
|
||||
@ -1674,6 +1696,11 @@ if ($action == 'exportsite')
|
||||
readfile($fileofzip);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Import site
|
||||
@ -2205,7 +2232,53 @@ if (! GETPOST('hide_websitemenu'))
|
||||
print '<!-- button EditInLine and ShowSubcontainers -->'."\n";
|
||||
print '<div class="websiteselectionsection inline-block">';
|
||||
print '<div class="inline-block">';
|
||||
|
||||
print '<span id="switchckeditorinline">';
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').';
|
||||
if (isEditingEnabled)
|
||||
{
|
||||
switchEditorOnline(true);
|
||||
}
|
||||
|
||||
$( "#switchckeditorinline" ).click(function() {
|
||||
switchEditorOnline();
|
||||
});
|
||||
|
||||
function switchEditorOnline(forceenable)
|
||||
{
|
||||
if (! isEditingEnabled || forceenable)
|
||||
{
|
||||
console.log("Enable inline edit");
|
||||
jQuery(\'section[contenteditable="true"]\').each(function(idx){
|
||||
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.
|
||||
extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
|
||||
removePlugins: \'stylescombo\',
|
||||
// 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>';
|
||||
print $langs->trans("EditInLine");
|
||||
print '</span>';
|
||||
|
||||
if ($websitepage->grabbed_from)
|
||||
{
|
||||
//print '<input type="submit" class="button nobordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
@ -2223,6 +2296,7 @@ if (! GETPOST('hide_websitemenu'))
|
||||
print '<a class="button nobordertransp nohoverborder"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOn"), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '<div class="inline-block">';
|
||||
print $langs->trans("ShowSubcontainers");
|
||||
@ -2488,6 +2562,21 @@ if ($action == 'editcss')
|
||||
//$manifestjsoncontent.="";
|
||||
}
|
||||
|
||||
if (GETPOST('editcss', 'alpha') || GETPOST('refreshpage', 'alpha'))
|
||||
{
|
||||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
$readmecontent = GETPOST('WEBSITE_README');
|
||||
}
|
||||
if (! trim($readmecontent))
|
||||
{
|
||||
//$readmecontent.="";
|
||||
}
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<!-- Edit CSS -->'."\n";
|
||||
@ -2516,7 +2605,8 @@ if ($action == 'editcss')
|
||||
|
||||
// CSS file
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_CSS_INLINE');
|
||||
$htmlhelp=$langs->trans("CSSContentTooltipHelp");
|
||||
print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip');
|
||||
print '</td><td>';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
@ -2536,9 +2626,12 @@ if ($action == 'editcss')
|
||||
|
||||
// Common HTML header
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_HTML_HEADER');
|
||||
$htmlhelp=$langs->trans("Example").' :<br>';
|
||||
$htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault);
|
||||
print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
|
||||
$textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
|
||||
$htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>';
|
||||
print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2');
|
||||
print '</td><td>';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
@ -2578,6 +2671,17 @@ if ($action == 'editcss')
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// README.md
|
||||
print '<tr><td class="tdtop">';
|
||||
$htmlhelp=$langs->trans("EnterHereLicenseInformation");
|
||||
print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip');
|
||||
print '</td><td>';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text');
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -2924,7 +3028,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
||||
if ($action != 'createcontainer')
|
||||
{
|
||||
print '<tr><td>';
|
||||
print $langs->trans('LastModificationAuthor');
|
||||
print $langs->trans('UserModif');
|
||||
print '</td><td>';
|
||||
if ($pageusermodifid > 0)
|
||||
{
|
||||
@ -3057,9 +3161,10 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm')
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="replacesiteconfirm">';
|
||||
print '<input type="hidden" name="website" value="'.$website->ref.'">';
|
||||
|
||||
|
||||
print '<!-- Edit Media -->'."\n";
|
||||
print '<!-- Replace string -->'."\n";
|
||||
print '<div class="fiche"><br>';
|
||||
|
||||
print load_fiche_titre($langs->trans("ReplaceWebsiteContent"));
|
||||
@ -3141,6 +3246,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
|
||||
// Ouput page under the Dolibarr top menu
|
||||
$objectpage->fetch($pageid);
|
||||
|
||||
$jscontent = @file_get_contents($filejs);
|
||||
|
||||
$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";
|
||||
@ -3155,6 +3261,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
$out.="\n<html><head>\n";
|
||||
$out.="<!-- htmlheader/style of page from database -->\n";
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader');
|
||||
|
||||
$out.="<!-- htmlheader/style of website from files -->\n";
|
||||
// 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;
|
||||
}
|
||||
*/
|
||||
|
||||
$out.="</head>\n";
|
||||
$out.="\n<body>";
|
||||
|
||||
@ -3219,7 +3344,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
{
|
||||
// Keep the contenteditable="true" when mode Edit Inline is on
|
||||
}
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $newcontent)."\n";
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n";
|
||||
//$out.=$newcontent;
|
||||
|
||||
$out.='</div>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user