XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
install_insertData_theme.inc.php
1<?php
11
12// replace theme_default
13require_once dirname( __DIR__ ) . '/wizards/install_insertData.inc.php';
14
15$available_themes = [];
16foreach ( $_POST as $key => $value ) {
17 if ( preg_match( '/^option_themes_\d+$/', $key ) && preg_match( '/^\w+$/', $value ) ) {
18 $available_themes[] = $value;
19 }
20}
21if ( empty( $available_themes ) ) {
22 $available_themes = [ 'xcl_default', 'bs5-starter' ]; // !Todo Theme boilerplate, , 'xcl-darkmode'
23}
24
25$default_theme = 'xcl_default';
26if ( isset( $_POST['default_theme'] ) && preg_match( "/^\w+$/", $_POST['default_theme'] ) ) {
27 $default_theme = $_POST['default_theme'];
28 if ( ! in_array( $default_theme, $available_themes, true ) ) {
29 $available_themes[] = $default_theme;
30 }
31}
32
33$hd_query = [
34 sprintf( 'update %s set conf_value="%s" where conf_name="theme_set" limit 1',
35 $dbm->db->prefix( 'config' ), $default_theme ),
36 sprintf( 'update %s set conf_value=\'%s\' where conf_name="theme_set_allowed" limit 1',
37 $dbm->db->prefix( 'config' ), serialize( $available_themes ) ),
38 sprintf( 'update %s set theme="%s" where uid =1 limit 1',
39 $dbm->db->prefix( 'users' ), '' ),
40];
41
42foreach ( $hd_query as $hd_sql ) {
43 $result = $dbm->query( $hd_sql );
44}