123456789101112131415161718192021222324252627282930313233343536 |
- package modules
- import (
- "io/ioutil"
- "os"
- ThemeFiles "golang-fave/engine/assets/template"
- "golang-fave/engine/utils"
- "golang-fave/engine/wrapper"
- )
- func (this *Modules) RegisterAction_TemplatesRestoreFileAll() *Action {
- return this.newAction(AInfo{
- Mount: "templates-restore-file-all",
- WantAdmin: true,
- }, func(wrap *wrapper.Wrapper) {
- pf_file := utils.Trim(wrap.R.FormValue("file"))
- if pf_file != "all" {
- wrap.MsgError(`Inner system error`)
- return
- }
- for file, data := range ThemeFiles.AllData {
- if err := ioutil.WriteFile(wrap.DTemplate+string(os.PathSeparator)+file, data, 0664); err != nil {
- wrap.MsgError(err.Error())
- return
- }
- }
- wrap.ResetCacheBlocks()
- // Reload current page
- wrap.Write(`window.location.reload(false);`)
- })
- }
|