Merge branch 'develop' into feature-rest-api-bankaccounts-transfer
This commit is contained in:
commit
01ad2658d4
@ -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")
|
||||
|
||||
@ -30,14 +30,16 @@
|
||||
* @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...';
|
||||
@ -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);
|
||||
@ -97,6 +100,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
|
||||
$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;
|
||||
}
|
||||
@ -196,7 +200,7 @@ 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));
|
||||
|
||||
@ -322,10 +322,30 @@ function dolSaveManifestJson($file, $content)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -397,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);
|
||||
|
||||
|
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.
|
||||
@ -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;
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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));
|
||||
@ -855,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';
|
||||
}
|
||||
@ -1153,6 +1159,33 @@ if ($action == 'updatecss')
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
if (! $error)
|
||||
{
|
||||
@ -2529,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";
|
||||
@ -2557,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%', '');
|
||||
@ -2577,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%', '');
|
||||
@ -2619,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();
|
||||
@ -3281,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