diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 64e23642b60..fffa25cf728 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -412,8 +412,8 @@ class Website extends CommonObject $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' virtualhost = '.(($this->virtualhost != '')?"'".$this->db->escape($this->virtualhost)."'":"null").','; $sql .= ' fk_user_modif = '.(! isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; - $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null'); - $sql .= ', tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; + $sql .= ' tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 76d063393f8..5083f492266 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -181,6 +181,7 @@ $filehtaccess=$pathofwebsite.'/.htaccess'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; $filewrapper=$pathofwebsite.'/wrapper.php'; +$filemanifestjson=$pathofwebsite.'/manifest.json.php'; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); @@ -207,6 +208,47 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.='-->'."\n"; +$manifestjsoncontentdefault = ''; +$manifestjsoncontentdefault.= '{ + "name": "MyWebsite", + "short_name": "MyWebsite", + "start_url": "/", + "lang": "en-US", + "display": "standalone", + "background_color": "#fff", + "description": "A simple Web app.", + "icons": [{ + "src": "images/'.$website->ref.'/homescreen48.png", + "sizes": "48x48", + "type": "image/png" + }, { + "src": "image/'.$website->ref.'/homescreen72.png", + "sizes": "72x72", + "type": "image/png" + }, { + "src": "image/'.$website->ref.'/homescreen96.png", + "sizes": "96x96", + "type": "image/png" + }, { + "src": "image/'.$website->ref.'/homescreen144.png", + "sizes": "144x144", + "type": "image/png" + }, { + "src": "image/'.$website->ref.'/homescreen168.png", + "sizes": "168x168", + "type": "image/png" + }, { + "src": "image/'.$website->ref.'/homescreen192.png", + "sizes": "192x192", + "type": "image/png" + }], + "related_applications": [{ + "platform": "play", + "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro" + }] +}'; + + /* * Actions @@ -794,6 +836,13 @@ if ($action == 'addcontainer') $result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent); } + if (! dol_is_file($filemanifestjson)) + { + $manifestjsoncontent = ""; + $result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); + } + + $action = 'preview'; } } @@ -940,7 +989,7 @@ if ($action == 'updatecss') /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. $htmlheadercontent.= "\n";*/ - $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none'); - /*$htaccesscontent.= "\n".'"."\n";*/ - dol_syslog("Save file htaccess into ".$filehtaccess); dol_mkdir($pathofwebsite); @@ -1089,6 +1123,38 @@ if ($action == 'updatecss') setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); } + // manifest.json file + $manifestjsoncontent =''; + + $manifestjsoncontent.= "\n"; + + $manifestjsoncontent.= GETPOST('WEBSITE_MANIFEST_JSON', 'none'); + + $manifestjsoncontent.= "\n".'"."\n"; + + dol_syslog("Save file manifest.json.php into ".$manifestjsoncontent); + + 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'); + } + // Message if no error if (! $error) @@ -2382,7 +2448,22 @@ if ($action == 'editcss') $htaccesscontent.="# Order allow,deny\n"; $htaccesscontent.="# Deny from all\n"; } - //else $htaccesscontent=''."\n".$htaccesscontent."\n".'';*/ + + + if (GETPOST('editcss', 'alpha') || GETPOST('refreshpage', 'alpha')) + { + $manifestjsoncontent = @file_get_contents($filemanifestjson); + // Clean the manifestjson file to remove php code and get only html part + $manifestjsoncontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $manifestjsoncontent); + } + else + { + $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON'); + } + if (! trim($manifestjsoncontent)) + { + //$manifestjsoncontent.=""; + } dol_fiche_head(); @@ -2396,6 +2477,20 @@ if ($action == 'editcss') print $websitekey; print ''; + // VirtualHost + print '