diff --git a/ChangeLog b/ChangeLog index cb4ad0c3982..0839fd77e95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,7 +15,7 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * Properties ->libelle_incoterms were renamed into ->label_incoterms * Removed the method liste_array() of project class. It was not used by core code. - +* The function show_theme() hase been renamed into showSkins() ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 509a04494d2..37c997ee306 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -259,7 +259,7 @@ if ($action == 'edit') // Edit print '
'."\n"; // Themes and themes options - show_theme(null, 1); + showSkins(null, 1); print '
'; // Other @@ -464,7 +464,7 @@ else // Show // Themes - show_theme(null, 0); + showSkins(null, 0); print '
'; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e126ff2b7f0..92b739b3190 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -555,6 +555,7 @@ function dol_count_nb_of_line($file) * * @param string $pathoffile Path of file * @return integer File size + * @see dol_print_size() */ function dol_filesize($pathoffile) { @@ -2164,6 +2165,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $original_file=$dolibarr_main_data_root.'/'.$original_file; } + // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log + elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) + { + $accessallowed=($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); + $original_file=$dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; + } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index ea7f9856509..81e9c8dea73 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -295,10 +295,9 @@ function user_admin_prepare_head() * @param boolean $foruserprofile Show for user profile view * @return void */ -function show_theme($fuser, $edit = 0, $foruserprofile = false) +function showSkins($fuser, $edit = 0, $foruserprofile = false) { global $conf,$langs,$db,$form; - global $bc; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; @@ -351,9 +350,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) { print ''.$langs->trans("DefaultSkin").''; print ''; - $url='https://www.dolistore.com/lang-en/4-skins'; - if (preg_match('/fr/i', $langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes'; - //if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes'; + $url='https://www.dolistore.com/4-skins'; print ''; print $langs->trans('DownloadMoreSkins'); print ''; @@ -432,7 +429,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("TopMenuDisableImages").''; print ''.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).''; - print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); + print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -477,7 +474,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("TopMenuBackgroundColor").''; print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).''; - print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -524,7 +521,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("TopMenuBackgroundColor").''; print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).''; - print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -573,7 +570,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("TopMenuBackgroundColor").''; print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).''; - print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); + print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -763,7 +760,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("TopMenuBackgroundColor").''; print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).''; - print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); + print 'conf->THEME_ELDY_TEXTLINK)?" checked":""); print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -813,9 +810,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) /* Must first change option to choose color of highlight instead of yes or no. print ''; print ''.$langs->trans("HighlightLinesOnMouseHover").''; - print 'global->THEME_ELDY_USE_HOVER?" checked":"").'>'; - print ' '.$langs->trans("UsePersonalValue").''; - print ''; + print 'global->THEME_ELDY_USE_HOVER?" checked":"").'>'; + print ' '.$langs->trans("UsePersonalValue").''; + print ''; print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print ''; print ''; @@ -825,7 +822,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("HighlightLinesColor").''; print ''; - //print ''; + //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; if ($edit) { @@ -856,9 +853,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) /* Must first change option to choose color of highlight instead of yes or no. print ''; print ''.$langs->trans("HighlightLinesOnMouseHover").''; - print 'global->THEME_ELDY_USE_HOVER?" checked":"").'>'; - print ' '.$langs->trans("UsePersonalValue").''; - print ''; + print 'global->THEME_ELDY_USE_HOVER?" checked":"").'>'; + print ' '.$langs->trans("UsePersonalValue").''; + print ''; print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print ''; print ''; @@ -869,7 +866,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false) print ''; print ''.$langs->trans("HighlightLinesChecked").''; print ''; - //print ''; + //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; if ($edit) { diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 78da87a8fe4..e9507b8556d 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -622,7 +622,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25) if (empty($arrayresult['list'])) { $arrayresult['code']='KO'; - $arrayresult['message']=$weblangs->trans("NothingFound"); + $arrayresult['message']=$weblangs->trans("NoRecordFound"); } } else @@ -819,313 +819,3 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } } } - - - -/** - * Save content of a page on disk - * - * @param string $filemaster Full path of filename master.inc.php for website to generate - * @return boolean True if OK - */ -function dolSaveMasterFile($filemaster) -{ - global $conf; - - // Now generate the master.inc.php page - dol_syslog("We regenerate the master file"); - dol_delete_file($filemaster); - - $mastercontent = ''."\n"; - $result = file_put_contents($filemaster, $mastercontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); - - return $result; -} - -/** - * Save content of a page on disk - * - * @param string $filealias Full path of filename to generate - * @param Website $object Object website - * @param WebsitePage $objectpage Object websitepage - * @return boolean True if OK - */ -function dolSavePageAlias($filealias, $object, $objectpage) -{ - global $conf; - - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) - dol_syslog("We regenerate the alias page filealias=".$filealias); - - $aliascontent = 'id.'.tpl.php\'; '; - $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; - $aliascontent.= '?>'."\n"; - $result = file_put_contents($filealias, $aliascontent); - if (! empty($conf->global->MAIN_UMASK)) { - @chmod($filealias, octdec($conf->global->MAIN_UMASK)); - } - - return ($result?true:false); -} - - -/** - * Save content of a page on disk - * - * @param string $filetpl Full path of filename to generate - * @param Website $object Object website - * @param WebsitePage $objectpage Object websitepage - * @return boolean True if OK - */ -function dolSavePageContent($filetpl, $object, $objectpage) -{ - global $conf; - - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) - dol_syslog("We regenerate the tpl page filetpl=".$filetpl); - - dol_delete_file($filetpl); - - $shortlangcode = ''; - if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en - - $tplcontent =''; - $tplcontent.= "\n"; - if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5)) - { - $tplcontent.= "\n"; - } - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n"; - $tplcontent.= ''."\n"; - - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= $objectpage->content."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - - $tplcontent.= '"."\n"; - - //var_dump($filetpl);exit; - $result = file_put_contents($filetpl, $tplcontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); - - return $result; -} - - -/** - * Save content of the index.php and wrapper.php page - * - * @param string $pathofwebsite Path of website root - * @param string $fileindex Full path of file index.php - * @param string $filetpl File tpl to index.php page redirect to - * @param string $filewrapper Full path of file wrapper.php - * @return boolean True if OK - */ -function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) -{ - global $conf; - - $result1=false; - $result2=false; - - dol_mkdir($pathofwebsite); - - dol_delete_file($fileindex); - $indexcontent = ''."\n"; - $result1 = file_put_contents($fileindex, $indexcontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); - - dol_delete_file($filewrapper); - - $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); - - $result2 = file_put_contents($filewrapper, $wrappercontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); - - return ($result1 && $result2); -} - - -/** - * Save content of a page on disk - * - * @param string $filehtmlheader Full path of filename to generate - * @param string $htmlheadercontent Content of file - * @return boolean True if OK - */ -function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent) -{ - global $conf, $pathofwebsite; - - dol_syslog("Save html header into ".$filehtmlheader); - - dol_mkdir($pathofwebsite); - $result = file_put_contents($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; -} - -/** - * Save content of a page on disk - * - * @param string $filecss Full path of filename to generate - * @param string $csscontent Content of file - * @return boolean True if OK - */ -function dolSaveCssFile($filecss, $csscontent) -{ - global $conf, $pathofwebsite; - - dol_syslog("Save css file into ".$filecss); - - dol_mkdir($pathofwebsite); - $result = file_put_contents($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; -} - -/** - * Save content of a page on disk - * - * @param string $filejs Full path of filename to generate - * @param string $jscontent Content of file - * @return boolean True if OK - */ -function dolSaveJsFile($filejs, $jscontent) -{ - global $conf, $pathofwebsite; - - dol_syslog("Save js file into ".$filejs); - - dol_mkdir($pathofwebsite); - $result = file_put_contents($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; -} - -/** - * Save content of a page on disk - * - * @param string $filerobot Full path of filename to generate - * @param string $robotcontent Content of file - * @return boolean True if OK - */ -function dolSaveRobotFile($filerobot, $robotcontent) -{ - global $conf, $pathofwebsite; - - dol_syslog("Save robot file into ".$filerobot); - - dol_mkdir($pathofwebsite); - $result = file_put_contents($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; -} - -/** - * Save content of a page on disk - * - * @param string $filehtaccess Full path of filename to generate - * @param string $htaccess Content of file - * @return boolean True if OK - */ -function dolSaveHtaccessFile($filehtaccess, $htaccess) -{ - global $conf, $pathofwebsite; - - dol_syslog("Save htaccess file into ".$filehtaccess); - - dol_mkdir($pathofwebsite); - $result = file_put_contents($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; -} diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php new file mode 100644 index 00000000000..903b8a8d144 --- /dev/null +++ b/htdocs/core/lib/website2.lib.php @@ -0,0 +1,430 @@ + + * + * 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 + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/lib/website2.lib.php + * \ingroup website + * \brief Library for website module (rare functions not required for execution of website) + */ + + + +/** + * Save content of a page on disk + * + * @param string $filemaster Full path of filename master.inc.php for website to generate + * @return boolean True if OK + */ +function dolSaveMasterFile($filemaster) +{ + global $conf; + + // Now generate the master.inc.php page + dol_syslog("We regenerate the master file"); + dol_delete_file($filemaster); + + $mastercontent = ''."\n"; + $result = file_put_contents($filemaster, $mastercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); + + return $result; +} + +/** + * Save content of a page on disk + * + * @param string $filealias Full path of filename to generate + * @param Website $object Object website + * @param WebsitePage $objectpage Object websitepage + * @return boolean True if OK + */ +function dolSavePageAlias($filealias, $object, $objectpage) +{ + global $conf; + + // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) + dol_syslog("We regenerate the alias page filealias=".$filealias); + + $aliascontent = 'id.'.tpl.php\'; '; + $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; + $aliascontent.= '?>'."\n"; + $result = file_put_contents($filealias, $aliascontent); + if (! empty($conf->global->MAIN_UMASK)) { + @chmod($filealias, octdec($conf->global->MAIN_UMASK)); + } + + return ($result?true:false); +} + + +/** + * Save content of a page on disk + * + * @param string $filetpl Full path of filename to generate + * @param Website $object Object website + * @param WebsitePage $objectpage Object websitepage + * @return boolean True if OK + */ +function dolSavePageContent($filetpl, $object, $objectpage) +{ + global $conf; + + // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) + dol_syslog("We regenerate the tpl page filetpl=".$filetpl); + + dol_delete_file($filetpl); + + $shortlangcode = ''; + if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en + + $tplcontent =''; + $tplcontent.= "\n"; + if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5)) + { + $tplcontent.= "\n"; + } + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n"; + $tplcontent.= ''."\n"; + + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= $objectpage->content."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + + $tplcontent.= '"."\n"; + + //var_dump($filetpl);exit; + $result = file_put_contents($filetpl, $tplcontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); + + return $result; +} + + +/** + * Save content of the index.php and wrapper.php page + * + * @param string $pathofwebsite Path of website root + * @param string $fileindex Full path of file index.php + * @param string $filetpl File tpl to index.php page redirect to + * @param string $filewrapper Full path of file wrapper.php + * @return boolean True if OK + */ +function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) +{ + global $conf; + + $result1=false; + $result2=false; + + dol_mkdir($pathofwebsite); + + dol_delete_file($fileindex); + $indexcontent = ''."\n"; + $result1 = file_put_contents($fileindex, $indexcontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); + + dol_delete_file($filewrapper); + + $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); + + $result2 = file_put_contents($filewrapper, $wrappercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); + + return ($result1 && $result2); +} + + +/** + * Save content of a page on disk + * + * @param string $filehtmlheader Full path of filename to generate + * @param string $htmlheadercontent Content of file + * @return boolean True if OK + */ +function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save html header into ".$filehtmlheader); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($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; +} + +/** + * Save content of a page on disk + * + * @param string $filecss Full path of filename to generate + * @param string $csscontent Content of file + * @return boolean True if OK + */ +function dolSaveCssFile($filecss, $csscontent) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save css file into ".$filecss); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($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; +} + +/** + * Save content of a page on disk + * + * @param string $filejs Full path of filename to generate + * @param string $jscontent Content of file + * @return boolean True if OK + */ +function dolSaveJsFile($filejs, $jscontent) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save js file into ".$filejs); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($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; +} + +/** + * Save content of a page on disk + * + * @param string $filerobot Full path of filename to generate + * @param string $robotcontent Content of file + * @return boolean True if OK + */ +function dolSaveRobotFile($filerobot, $robotcontent) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save robot file into ".$filerobot); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($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; +} + +/** + * Save content of a page on disk + * + * @param string $filehtaccess Full path of filename to generate + * @param string $htaccess Content of file + * @return boolean True if OK + */ +function dolSaveHtaccessFile($filehtaccess, $htaccess) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save htaccess file into ".$filehtaccess); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($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; +} + + + +/** + * Show list of themes. Show all thumbs of themes + * + * @param Website $website Object website to load the tempalte into + * @return void + */ +function showWebsiteTemplates(Website $website) +{ + global $conf,$langs,$db,$form; + global $bc; + + $dirthemes=array('/doctemplates/websites'); + if (! empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application + { + foreach($conf->modules_parts['websitetemplates'] as $reldir) + { + $dirthemes=array_merge($dirthemes, (array) ($reldir.'doctemplates/websites')); + } + } + $dirthemes=array_unique($dirthemes); + // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme') + + $colspan=2; + + $thumbsbyrow=6; + print ''; + + // Title + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print '
'; + $url='https://www.dolistore.com/43-web-site-templates'; + print ''; + print $langs->trans('DownloadMoreSkins'); + print ''; + print '
'.$langs->trans("ThemeDir").''; + foreach($dirthemes as $dirtheme) + { + echo '"'.$dirtheme.'" '; + } + print '
'; + + print '
'; + + $i=0; + foreach($dirthemes as $dir) + { + //print $dirroot.$dir;exit; + $dirtheme=DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root + if (is_dir($dirtheme)) + { + $handle=opendir($dirtheme); + if (is_resource($handle)) + { + while (($subdir = readdir($handle))!==false) + { + if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' + && substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir)) + { + $subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir); + + // Disable not stable themes (dir ends with _exp or _dev) + if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue; + if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue; + + print '
'; + + $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 ''.$title.''; + print '
'; + print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')'; + print '
ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").''; + print '
'; + + $i++; + } + } + } + } + } + + print '
'; + + print '
'; +} diff --git a/htdocs/install/doctemplates/websites/website-template-corporate.jpg b/htdocs/install/doctemplates/websites/website-template-corporate.jpg new file mode 100644 index 00000000000..a693fb4395e Binary files /dev/null and b/htdocs/install/doctemplates/websites/website-template-corporate.jpg differ diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1cadc32f4ab..880978a13e5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -28,6 +28,7 @@ NoTemplateDefined=No template available for this email type AvailableVariables=Available substitution variables NoTranslation=No translation Translation=Translation +EmptySearchString=Enter a non empty search string NoRecordFound=No record found NoRecordDeleted=No record deleted NotEnoughDataYet=Not enough data diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 433e35e2d1b..efad38c14f5 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -14,6 +14,7 @@ WEBSITE_JS_INLINE=Javascript file content (common to all pages) 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 HtmlHeaderPage=HTML header (specific to this page only) PageNameAliasHelp=Name or alias of the page.
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 "%s" 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. @@ -89,7 +90,8 @@ AliasPageAlreadyExists=Alias page %s already exists CorporateHomePage=Corporate Home page EmptyPage=Empty page ExternalURLMustStartWithHttp=External URL must start with http:// or https:// -ZipOfWebsitePackageToImport=Zip file of website package +ZipOfWebsitePackageToImport=Upload the Zip file of the website template package +ZipOfWebsitePackageToLoad=or Choose an available embedded website template package ShowSubcontainers=Include dynamic content InternalURLOfPage=Internal URL of page ThisPageIsTranslationOf=This page/container is a translation of @@ -101,5 +103,4 @@ NotAllowedToAddDynamicContent=You don't have permission to add or edit PHP dynam ReplaceWebsiteContent=Search or Replace website content DeleteAlsoJs=Delete also all javascript files specific to this website? DeleteAlsoMedias=Delete also all medias files specific to this website? -# Export MyWebsitePages=My website pages \ No newline at end of file diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index c33c26fa95b..30dc17fa0a7 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -314,7 +314,7 @@ if ($action == 'edit') print '
'; // Theme - show_theme($object, (($user->admin || empty($dolibarr_main_demo))?1:0), true); + showSkins($object, (($user->admin || empty($dolibarr_main_demo))?1:0), true); dol_fiche_end(); @@ -387,7 +387,7 @@ else // Skin - show_theme($object, 0, true); + showSkins($object, 0, true); dol_fiche_end(); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 69ab71e62ed..8dc38eb2ae1 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -94,7 +94,7 @@ $entity=GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; // Security check if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1); -if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') accessforbidden('Bad link. Missing identification to find file (original_file or hashp)', 0, 0, 1); +if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') accessforbidden('Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1); if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5083f492266..77b70261a4c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php'; @@ -1671,14 +1672,14 @@ if ($action == 'exportsite') // Import site if ($action == 'importsiteconfirm') { - if (empty($_FILES)) + if (empty($_FILES) && ! GETPOSTISSET('templateuserfile')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; } else { - if (! empty($_FILES)) + if (! empty($_FILES) || GETPOSTISSET('templateuserfile')) { // Check symlink to medias and restore it if ko $pathtomedias=DOL_DATA_ROOT.'/medias'; @@ -1695,29 +1696,37 @@ if ($action == 'importsiteconfirm') } } - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; - else $userfiles=array($_FILES['userfile']['tmp_name']); - - foreach($userfiles as $key => $userfile) + $fileofzip = ''; + if (GETPOSTISSET('templateuserfile')) { - if (empty($_FILES['userfile']['tmp_name'][$key])) + $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); + } + elseif (! empty($_FILES)) + { + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; + else $userfiles=array($_FILES['userfile']['tmp_name']); + + foreach($userfiles as $key => $userfile) { - $error++; - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ - setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); - $action = 'importsite'; - } - else { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); - $action = 'importsite'; + if (empty($_FILES['userfile']['tmp_name'][$key])) + { + $error++; + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); + $action = 'importsite'; + } + else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); + $action = 'importsite'; + } } } - } - if (! $error) - { - $upload_dir = $conf->website->dir_temp; - $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); + if (! $error) + { + $upload_dir = $conf->website->dir_temp; + $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); + } // Get name of file (take last one if several name provided) $fileofzip = $upload_dir.'/unknown'; @@ -1728,7 +1737,10 @@ if ($action == 'importsiteconfirm') $fileofzip = $upload_dir . '/' .$ifile2; } } + } + if (! $error) + { $result = $object->importWebSite($fileofzip); if ($result < 0) { @@ -2648,12 +2660,20 @@ if ($action == 'importsite') dol_fiche_head(array(), '0', '', -1); - print $langs->trans("ZipOfWebsitePackageToImport").'

'; + print ''.$langs->trans("ZipOfWebsitePackageToImport").'

'; print ''; print ''; print ''; + print '


'; + + + print ''.$langs->trans("ZipOfWebsitePackageToLoad").'

'; + + showWebsiteTemplates($website); + + dol_fiche_end(); print '';