3
3
/**
4
4
* @Author: nguyen
5
5
* @Date: 2020-05-31 14:56:43
6
- * @Last Modified by: nguyen
7
- * @Last Modified time: 2020-06-12 13:57:13
6
+ * @Last Modified by: Alex Dong
7
+ * @Last Modified time: 2020-06-12 16:21:00
8
8
*/
9
9
10
10
namespace Magepow \Theme \Controller \Adminhtml \Index ;
@@ -38,6 +38,8 @@ public function execute()
38
38
$ parentTheme = $ data ['parent_theme ' ];
39
39
$ themeTitle = $ data ['theme_title ' ];
40
40
$ themePath = isset ($ data ['theme_path ' ]) ? $ data ['theme_path ' ] : $ model ->getThemePath ();
41
+ $ themePath = trim ($ themePath );
42
+ $ themePath = str_replace (' ' , '_ ' , $ themePath );;
41
43
42
44
if ($ id && in_array ($ themePath , $ this ->defaultTheme )){
43
45
$ this ->messageManager ->addError (__ ('You can \'t edit default theme %1. ' , $ themePath ));
@@ -48,7 +50,7 @@ public function execute()
48
50
$ frontend = 'design ' . DIRECTORY_SEPARATOR . 'frontend ' ;
49
51
$ dir = $ this ->_filesystem ->getDirectoryWrite (DirectoryList::APP );
50
52
$ theme = $ this ->_objectManager ->create ('Magento\Theme\Model\Theme ' );
51
- if (!preg_match ('/[a-zA-Z0-9_]*[a-zA-Z0-9_]\/ [a-zA-Z0-9_]*[a-zA-Z0-9_] / ' , $ themePath )){
53
+ if (!preg_match ('/^ [a-zA-Z0-9_]+\/+ [a-zA-Z0-9_]+$ / ' , $ themePath )){
52
54
$ this ->messageManager ->addError (__ ('Theme Path %1 wrong format ' , $ themePath ));
53
55
$ this ->_getSession ()->setFormData ($ data );
54
56
return $ resultRedirect ->setPath ('*/*/edit ' );
@@ -80,7 +82,7 @@ public function execute()
80
82
}
81
83
82
84
$ dir ->writeFile ($ filePathXml , 'tmp ' );
83
-
85
+ $ data [ ' theme_path ' ] = $ themePath ;
84
86
$ data ['parent_id ' ] = $ parent ->getData ('theme_id ' );
85
87
$ data ['theme_title ' ] = $ parent ->getData ('theme_title ' );
86
88
$ data ['preview_image ' ] = NULL ;
0 commit comments