@@ -150,10 +150,10 @@ private function loadThemeAssets() {
150
150
}
151
151
152
152
function index () {
153
- $ theme = sanitizeFileName ( $ this ->request -> get [ ' theme ' ] ?? false );
153
+ $ theme = $ this ->getTheme ( );
154
154
$ themeParam = ($ theme ? '&theme= ' . $ theme : '' );
155
155
$ view = View::getInstance ();
156
- $ view ->themeBaseUrl = PUBLIC_PATH . 'themes/ ' . ( $ this -> getTheme () ?? ' default ' ) . '/ ' ;
156
+ $ view ->themeBaseUrl = PUBLIC_PATH . 'themes/ ' . $ theme . '/ ' ;
157
157
$ view ->pages = $ this ->loadTemplateList ($ theme );
158
158
159
159
$ this ->loadThemeAssets ();
@@ -169,7 +169,7 @@ function index() {
169
169
170
170
foreach ($ results ['posts ' ] as $ post ) {
171
171
$ slug = $ post ['slug ' ];
172
- $ url = url ('content/page/index ' ,['slug ' => $ slug ]);
172
+ $ url = url ('content/page/index ' ,['slug ' => $ slug, ' post_id ' => $ post [ ' post_id ' ] ]);
173
173
174
174
$ posts [$ slug ] = [
175
175
'name ' => $ slug ,
@@ -378,7 +378,7 @@ function rename() {
378
378
}
379
379
380
380
$ currentFile = $ themeFolder . DS . $ file ;
381
- $ targetFile = dirname ($ currentFile ) . DS . basename ($ newfile ); //save in same folder
381
+ $ targetFile = dirname ($ currentFile ) . DS . slugify ( basename ($ newfile) ); //save in same folder
382
382
383
383
$ message = ['success ' => false , 'message ' => __ ('Error! ' )];
384
384
@@ -421,37 +421,42 @@ function rename() {
421
421
$ site_id [] = $ item ['site_id ' ];
422
422
}
423
423
}
424
-
424
+
425
425
$ startTemplateUrl = $ data ['template ' ] ?? "content/ $ type.html " ;
426
- $ template = "content/ $ slug.html " ;
427
-
428
- if (!@copy ($ themeFolder . DS . $ startTemplateUrl , $ themeFolder . DS . $ template )) {
426
+ $ template = "content/ $ slug.html " ;
427
+
428
+ if (! @copy ($ themeFolder . DS . $ startTemplateUrl , $ themeFolder . DS . $ template )) {
429
429
$ template = $ data ['template ' ] ?? '' ;
430
430
}
431
-
431
+
432
432
$ result = $ this ->posts ->add ([
433
433
'post ' => [
434
434
'post_content ' => $ data ['post_content ' ],
435
435
'taxonomy_item ' => $ taxonomy_item ?? [],
436
- 'template ' => $ template ,
436
+ 'template ' => $ template ,
437
437
] + $ data ,
438
438
'site_id ' => $ site_id ,
439
439
]);
440
440
441
441
if ($ result && isset ($ result ['post ' ])) {
442
- $ message = ['success ' => true , 'url ' => url ('content/page/index ' , ['slug ' => $ slug ]), 'message ' => ucfirst ($ type ) . __ (' duplicated! ' ) ];
442
+ $ message = ['success ' => true , 'url ' => url ('content/page/index ' , ['slug ' => $ slug, ' post_id ' => $ post_id ]), 'message ' => ucfirst ($ type ) . ' ' . __ ('duplicated ' ) . ' ! ' ];
443
443
} else {
444
444
$ message = ['success ' => false , 'message ' => sprintf (__ ('Error duplicating %s! ' ), $ type )];
445
445
}
446
446
}
447
447
} else {
448
- $ result = $ this ->posts ->editContent ($ options );
449
- }
450
-
451
- if ($ result && isset ($ result ['post_content ' ])) {
452
- $ message = ['success ' => true , 'url ' => url ('content/page/index ' , ['slug ' => $ slug ]), 'message ' => ucfirst ($ type ) . __ (' renamed! ' )];
453
- } else {
454
- $ message = ['success ' => false , 'message ' => sprintf (__ ('Error renaming %s! ' ), $ type )];
448
+ $ data = [
449
+ 'post_content ' => ['name ' => $ name , 'slug ' => $ slug ],
450
+ 'post_id ' => $ post_id ,
451
+ 'language_id ' => $ this ->global ['language_id ' ],
452
+ ];
453
+ $ result = $ this ->posts ->editContent ($ data );
454
+
455
+ if ($ result && isset ($ result ['post_content ' ])) {
456
+ $ message = ['success ' => true , 'url ' => url ('content/page/index ' , ['slug ' => $ slug , 'post_id ' => $ post_id ]), 'message ' => ucfirst ($ type ) . ' ' . __ ('renamed ' ) . '! ' ];
457
+ } else {
458
+ $ message = ['success ' => false , 'message ' => sprintf (__ ('Error renaming %s! ' ), $ type )];
459
+ }
455
460
}
456
461
}
457
462
} else {
@@ -598,14 +603,15 @@ function save() {
598
603
599
604
//if plugins template use public path
600
605
$ isPlugin = false ;
606
+
601
607
if (substr_compare ($ file ,'/plugins/ ' , 0 , 9 ) === 0 ) {
602
608
$ fileName = DIR_PUBLIC . DS . ($ folder ? $ folder . DS : '' ) . $ file ;
603
609
$ isPlugin = true ;
604
610
} else {
605
611
$ fileName = $ themeFolder . DS . ($ folder ? $ folder . DS : '' ) . $ file ;
606
612
}
607
-
608
- if (! $ startTemplateUrl && !$ isPlugin ) {
613
+
614
+ if (! $ startTemplateUrl && ! $ isPlugin ) {
609
615
$ backupFolder = $ themeFolder . DS . 'backup ' . DS ;
610
616
611
617
if (is_writable ($ backupFolder )) {
0 commit comments