1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Automagical Info file builder
|
6
|
*
|
7
|
* This is the theme info backed up to a file. Its formatted and holds all
|
8
|
* current values - useful for migration or simply capturing the current
|
9
|
* theme settings as defaults.
|
10
|
*/
|
11
|
function at_core_submit_info($values, $theme_name, $path) {
|
12
|
$theme_settings = $values;
|
13
|
if ($theme_settings) {
|
14
|
$dynamic_settings_info = array();
|
15
|
$static_settings_info = array();
|
16
|
$lt = list_themes();
|
17
|
foreach ($lt as $key => $value) {
|
18
|
if ($theme_name == $key) {
|
19
|
$this_themes_info = $lt[$theme_name]->info;
|
20
|
foreach ($this_themes_info as $k => $v) {
|
21
|
// Basic info - name, desc, base theme, release, core, engine and screenshot
|
22
|
if ($k == 'name') {
|
23
|
$static_settings_info[] = 'name = ' . $v;
|
24
|
}
|
25
|
if ($k == 'description') {
|
26
|
$v = $v ? $v : $theme_name . ' is rocking the hardest!';
|
27
|
$static_settings_info[] = 'description = ' . $v;
|
28
|
}
|
29
|
if ($k == 'base theme') {
|
30
|
$static_settings_info[] = 'base theme = ' . $v;
|
31
|
}
|
32
|
if ($k == 'release') {
|
33
|
$static_settings_info[] = 'release = ' . $v;
|
34
|
}
|
35
|
if ($k == 'core') {
|
36
|
$static_settings_info[] = 'core = 7.x';
|
37
|
}
|
38
|
if ($k == 'engine') {
|
39
|
$static_settings_info[] = 'engine = phptemplate';
|
40
|
}
|
41
|
if ($k == 'screenshot') {
|
42
|
$static_settings_info[] = 'screenshot = screenshot.png';
|
43
|
}
|
44
|
// Stylesheets
|
45
|
if ($k == 'stylesheets' && !empty($k)) {
|
46
|
foreach ($v as $media_target => $stylesheet_file) {
|
47
|
foreach ($stylesheet_file as $stylesheet_file_name => $stylesheet_file_path) {
|
48
|
$static_settings_info[] = "stylesheets[$media_target][] = $stylesheet_file_name";
|
49
|
}
|
50
|
}
|
51
|
}
|
52
|
// IE Stylesheets
|
53
|
if ($k == 'ie_stylesheets' && !empty($k)) {
|
54
|
foreach ($v as $media_target => $condition) {
|
55
|
foreach ($condition as $conditional_comment => $condition_file) {
|
56
|
foreach ($condition_file as $conditional_file_path) {
|
57
|
$static_settings_info[] = "ie_stylesheets[$media_target][$conditional_comment][] = $conditional_file_path";
|
58
|
}
|
59
|
}
|
60
|
}
|
61
|
}
|
62
|
// Scripts
|
63
|
if ($k == 'scripts' && !empty($k)) {
|
64
|
foreach ($v as $script => $file) {
|
65
|
$static_settings_info[] = "scripts[] = $script";
|
66
|
}
|
67
|
}
|
68
|
// IE Scripts
|
69
|
if ($k == 'ie_scripts' && !empty($k)) {
|
70
|
foreach ($v as $condition => $condition_file) {
|
71
|
foreach ($condition_file as $conditional_file_path) {
|
72
|
$static_settings_info[] = "ie_scripts[$condition][] = $conditional_file_path";
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
// Regions
|
77
|
if ($k == 'regions') {
|
78
|
foreach ($v as $name => $label) {
|
79
|
$static_settings_info[] = "regions[$name] = $label";
|
80
|
}
|
81
|
}
|
82
|
// Features
|
83
|
if ($k == 'features') {
|
84
|
foreach ($v as $feature_key => $feature) {
|
85
|
$static_settings_info[] = "features[] = $feature";
|
86
|
}
|
87
|
}
|
88
|
}
|
89
|
}
|
90
|
}
|
91
|
if (!empty($static_settings_info)) {
|
92
|
$static_settings = implode("\n", $static_settings_info);
|
93
|
}
|
94
|
// Might need to check this and add some more exclusions
|
95
|
$exclusions = array(
|
96
|
'var',
|
97
|
'default_logo',
|
98
|
'logo_path',
|
99
|
'logo_upload',
|
100
|
'default_favicon',
|
101
|
'favicon_path',
|
102
|
'favicon_upload',
|
103
|
'submit',
|
104
|
'form_build_id',
|
105
|
'form_token',
|
106
|
'form_id',
|
107
|
'check',
|
108
|
'output',
|
109
|
'op',
|
110
|
'scheme',
|
111
|
'palette',
|
112
|
'theme',
|
113
|
'info',
|
114
|
'at-layout__active_tab',
|
115
|
'at-settings__active_tab',
|
116
|
'at__active_tab',
|
117
|
'header_upload' // noggin setting
|
118
|
);
|
119
|
foreach ($theme_settings as $setting_name => $setting_value) {
|
120
|
if ($setting_name == 'global_gutter_width') {
|
121
|
if (empty($setting_value)) {
|
122
|
$exclusions[] = 'global_gutter_width';
|
123
|
}
|
124
|
}
|
125
|
if (isset($setting_value) && $setting_value !== '<none>' && !in_array($setting_name, $exclusions)) {
|
126
|
if (empty($setting_value) && !is_numeric($setting_value)) {
|
127
|
$setting_value = "''";
|
128
|
}
|
129
|
$dynamic_settings_info[] = "settings[$setting_name] = $setting_value";
|
130
|
}
|
131
|
}
|
132
|
if (!empty($dynamic_settings_info)) {
|
133
|
$dynamic_settings_info = $dynamic_settings_info ? $dynamic_settings_info : "''";
|
134
|
$dynamic_settings = implode("\n", $dynamic_settings_info);
|
135
|
}
|
136
|
if (!empty($static_settings_info) && !empty($dynamic_settings_info)) {
|
137
|
$combined_values = $static_settings . "\n" . $dynamic_settings; // ideally run a sanity check but all of them convert entities
|
138
|
$filepath = $path . '/' . $theme_name . '_settings.info.txt';
|
139
|
file_unmanaged_save_data($combined_values, $filepath, FILE_EXISTS_REPLACE);
|
140
|
}
|
141
|
}
|
142
|
}
|