Make the code more efficient adding the theme default settings.
This commit is contained in:
parent
4c026f74d6
commit
f0b47a62ab
|
|
@ -27,7 +27,7 @@
|
||||||
if ($domains_processed == 1) {
|
if ($domains_processed == 1) {
|
||||||
|
|
||||||
//get the background images
|
//get the background images
|
||||||
$relative_path = PROJECT_PATH.'/themes/enhanced/images/backgrounds';
|
$relative_path = PROJECT_PATH.'/themes/default/images/backgrounds';
|
||||||
$backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path);
|
$backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path);
|
||||||
unset($array);
|
unset($array);
|
||||||
$x = 0;
|
$x = 0;
|
||||||
|
|
@ -35,54 +35,35 @@ if ($domains_processed == 1) {
|
||||||
if ($file != "." AND $file != ".."){
|
if ($file != "." AND $file != ".."){
|
||||||
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||||
if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") {
|
if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") {
|
||||||
$x++;
|
|
||||||
$array[$x]['default_setting_category'] = 'theme';
|
$array[$x]['default_setting_category'] = 'theme';
|
||||||
$array[$x]['default_setting_subcategory'] = 'background_image';
|
$array[$x]['default_setting_subcategory'] = 'background_image';
|
||||||
$array[$x]['default_setting_name'] = 'array';
|
$array[$x]['default_setting_name'] = 'array';
|
||||||
$array[$x]['default_setting_value'] = $relative_path.'/'.$file;
|
$array[$x]['default_setting_value'] = $relative_path.'/'.$file;
|
||||||
$array[$x]['default_setting_enabled'] = 'false';
|
$array[$x]['default_setting_enabled'] = 'false';
|
||||||
$array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.';
|
$array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.';
|
||||||
|
$x++;
|
||||||
}
|
}
|
||||||
if ($x > 300) { break; };
|
if ($x > 300) { break; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$set_session_theme){
|
|
||||||
//get default settings
|
|
||||||
$sql = "select * from v_default_settings ";
|
|
||||||
$sql .= "where default_setting_category = 'theme' ";
|
|
||||||
$sql .= "and default_setting_subcategory = 'background_image' ";
|
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
|
||||||
$prep_statement->execute();
|
|
||||||
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
||||||
unset($prep_statement);
|
|
||||||
|
|
||||||
$background_image_enabled = false;
|
|
||||||
//add theme default settings
|
|
||||||
foreach ($array as $row) {
|
|
||||||
$found = false;
|
|
||||||
foreach ($default_settings as $field) {
|
|
||||||
if ($field["default_setting_value"] == $row["default_setting_value"]) {
|
|
||||||
$found = true;
|
|
||||||
}
|
|
||||||
//enable_background_image is a new setting, if a user has any background images enabled we should turn it on
|
|
||||||
if ($field["default_setting_enabled"] == 'enabled') {
|
|
||||||
$background_image_enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$found) {
|
|
||||||
$orm = new orm;
|
|
||||||
$orm->name('default_settings');
|
|
||||||
$orm->save($row);
|
|
||||||
$message = $orm->message;
|
|
||||||
//print_r($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//define array of settings
|
//define array of settings
|
||||||
unset($array);
|
$array[$x]['default_setting_category'] = 'theme';
|
||||||
$x = 0;
|
$array[$x]['default_setting_subcategory'] = 'background_color';
|
||||||
|
$array[$x]['default_setting_name'] = 'array';
|
||||||
|
$array[$x]['default_setting_value'] = '#6c89b5';
|
||||||
|
$array[$x]['default_setting_enabled'] = 'true';
|
||||||
|
$array[$x]['default_setting_order'] = '0';
|
||||||
|
$array[$x]['default_setting_description'] = 'Set a background (HTML compatible) color.';
|
||||||
|
$x++;
|
||||||
|
$array[$x]['default_setting_category'] = 'theme';
|
||||||
|
$array[$x]['default_setting_subcategory'] = 'background_color';
|
||||||
|
$array[$x]['default_setting_name'] = 'array';
|
||||||
|
$array[$x]['default_setting_value'] = '#144794';
|
||||||
|
$array[$x]['default_setting_order'] = '1';
|
||||||
|
$array[$x]['default_setting_enabled'] = 'true';
|
||||||
|
$array[$x]['default_setting_description'] = 'Set a secondary background (HTML compatible) color, for a gradient effect.';
|
||||||
|
$x++;
|
||||||
$array[$x]['default_setting_category'] = 'theme';
|
$array[$x]['default_setting_category'] = 'theme';
|
||||||
$array[$x]['default_setting_subcategory'] = 'login_opacity';
|
$array[$x]['default_setting_subcategory'] = 'login_opacity';
|
||||||
$array[$x]['default_setting_name'] = 'text';
|
$array[$x]['default_setting_name'] = 'text';
|
||||||
|
|
@ -398,58 +379,6 @@ if ($domains_processed == 1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//define secondary background color array
|
|
||||||
unset($array);
|
|
||||||
$x = 0;
|
|
||||||
$array[$x]['default_setting_category'] = 'theme';
|
|
||||||
$array[$x]['default_setting_subcategory'] = 'background_color';
|
|
||||||
$array[$x]['default_setting_name'] = 'array';
|
|
||||||
$array[$x]['default_setting_value'] = '#6c89b5';
|
|
||||||
$array[$x]['default_setting_enabled'] = 'true';
|
|
||||||
$array[$x]['default_setting_order'] = '0';
|
|
||||||
$array[$x]['default_setting_description'] = 'Set a background (HTML compatible) color.';
|
|
||||||
$x++;
|
|
||||||
$array[$x]['default_setting_category'] = 'theme';
|
|
||||||
$array[$x]['default_setting_subcategory'] = 'background_color';
|
|
||||||
$array[$x]['default_setting_name'] = 'array';
|
|
||||||
$array[$x]['default_setting_value'] = '#144794';
|
|
||||||
$array[$x]['default_setting_order'] = '1';
|
|
||||||
$array[$x]['default_setting_enabled'] = 'true';
|
|
||||||
$array[$x]['default_setting_description'] = 'Set a secondary background (HTML compatible) color, for a gradient effect.';
|
|
||||||
|
|
||||||
if($set_session_theme){
|
|
||||||
foreach ($array as $index => $default_settings) {
|
|
||||||
$sub_category = $array[$index]['default_setting_subcategory'];
|
|
||||||
$idx = $array[$index]['default_setting_order'];
|
|
||||||
if($array[$index]['default_setting_enabled'] == 'true'){
|
|
||||||
$_SESSION['theme'][$sub_category][$idx] = $array[$index]['default_setting_value'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//add secondary background color separately, if missing
|
|
||||||
$sql = "select count(*) as num_rows from v_default_settings ";
|
|
||||||
$sql .= "where default_setting_category = 'theme' ";
|
|
||||||
$sql .= "and default_setting_subcategory = 'background_color' ";
|
|
||||||
$prep_statement = $db->prepare($sql);
|
|
||||||
if ($prep_statement) {
|
|
||||||
$prep_statement->execute();
|
|
||||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
||||||
unset($prep_statement);
|
|
||||||
if ($row['num_rows'] == 0) {
|
|
||||||
$orm = new orm;
|
|
||||||
$orm->name('default_settings');
|
|
||||||
foreach ($array as $index => $null) {
|
|
||||||
$orm->save($array[$index]);
|
|
||||||
}
|
|
||||||
$message = $orm->message;
|
|
||||||
//print_r($message);
|
|
||||||
}
|
|
||||||
unset($row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//unset the array variable
|
//unset the array variable
|
||||||
unset($array);
|
unset($array);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue