diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index a799d156ad..e40636dbaf 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -403,23 +403,6 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } elseif ($category == "provision" && $subcategory == "password" && $name == "var" ) { echo " \n"; - } - elseif ($category == "theme" && $subcategory == "background_images" && $name == "var") { - echo " \n"; } else { echo " \n"; } diff --git a/themes/enhanced/app_defaults.php b/themes/enhanced/app_defaults.php index b7a00bc709..7c8bfeb2e9 100644 --- a/themes/enhanced/app_defaults.php +++ b/themes/enhanced/app_defaults.php @@ -29,8 +29,6 @@ if ($domains_processed == 1) { //add theme settings default settings $sql = "select count(*) as num_rows from v_default_settings "; $sql .= "where default_setting_category = 'theme' "; - $sql .= "and default_setting_subcategory = 'background_images' "; - $sql .= "and default_setting_name = 'var' "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -39,15 +37,31 @@ if ($domains_processed == 1) { if ($row['num_rows'] == 0) { $x = 0; $array[$x]['default_setting_category'] = 'theme'; - $array[$x]['default_setting_subcategory'] = 'background_images'; - $array[$x]['default_setting_name'] = 'var'; - $array[$x]['default_setting_value'] = 'true'; + $array[$x]['default_setting_subcategory'] = 'background_image'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = ''; $array[$x]['default_setting_enabled'] = 'false'; - $array[$x]['default_setting_description'] = 'Enable background images in the selected template (where available).'; + $array[$x]['default_setting_description'] = 'Specify a folder path or file path/url to enable background image(s) within a selected compatible template.'; + $x++; + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'background_color_1'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = '#ffffff'; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Enter a background (HTML compatible) color.'; + $x++; + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'background_color_2'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = '#f0f2f6'; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Enter a secondary background (HTML compatible) color, for a gradient effect.'; $x++; $orm = new orm; $orm->name('default_settings'); $orm->save($array[0]); + $orm->save($array[1]); + $orm->save($array[2]); $message = $orm->message; //print_r($message); } diff --git a/themes/enhanced/template.php b/themes/enhanced/template.php index 8e28e267a5..e3c02d7e37 100644 --- a/themes/enhanced/template.php +++ b/themes/enhanced/template.php @@ -59,7 +59,12 @@ DIV#page { overflow: auto; } - + /* Set the position and dimensions of the background image. */ DIV#page-background { z-index: 0; @@ -69,6 +74,25 @@ DIV#page { width: 100%; height: 100%; } + + + .page-background-gradient { + background-color: ; + background-image: -ms-linear-gradient(top, 0%, 100%); + background-image: -moz-linear-gradient(top , 0%, 100%); + background-image: -o-linear-gradient(top , 0%, 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); + background-image: -webkit-linear-gradient(top , 0%, 100%); + background-image: linear-gradient(to bottom, 0%, 100%); + } + img { @@ -488,7 +512,14 @@ legend { } .main_content { - 0 && $_SESSION['theme']['background_images']['var'] == 'true') { ?> + 0 && + ( + isset($_SESSION['theme']['background_image']['text']) || + isset($_SESSION['theme']['background_color_1']['text']) || + isset($_SESSION['theme']['background_color_2']['text']) + )) { ?> background-color: #FFFFFF; background-attachment: fixed; opacity: 0.93; @@ -969,36 +1000,101 @@ legend { ?> 1000) { break; }; - $x++; + // check for background image + if (isset($_SESSION['theme']['background_image']['text'])) { + // background image is enabled + $image_extensions = array('jpg','jpeg','png','gif'); + + if ($_SESSION['theme']['background_image']['text'] != '') { + + // background image(s) specified, check if source is file or folder + if (in_array(strtolower(pathinfo($_SESSION['theme']['background_image']['text'], PATHINFO_EXTENSION)), $image_extensions)) { + $image_source = 'file'; } + else { + $image_source = 'folder'; + } + + // is source (file/folder) local or remote + if ( + substr($_SESSION['theme']['background_image']['text'], 0, 4) == 'http' + ) { + $source_path = $_SESSION['theme']['background_image']['text']; + } + else if (substr($_SESSION['theme']['background_image']['text'], 0, 1) == '/') { // + // use project path as root + $source_path = PROJECT_PATH.$_SESSION['theme']['background_image']['text']; + } + else { + // use theme images/backgrounds folder as root + $source_path = PROJECT_PATH.'/themes/enhanced/images/backgrounds/'.$_SESSION['theme']['background_image']['text']; + } + } - if (strlen($_SESSION['background_image'])== 0) { - $_SESSION['background_image'] = $v_background_array[array_rand($v_background_array, 1)]; + else { + // not set, so use default backgrounds folder and images + $image_source = 'folder'; + $source_path = PROJECT_PATH.'/themes/enhanced/images/backgrounds'; + } + + if ($image_source == 'folder') { + if (file_exists($_SERVER["DOCUMENT_ROOT"].$source_path)) { + // retrieve a random background image + $dir_list = opendir($_SERVER["DOCUMENT_ROOT"].$source_path); + $v_background_array = array(); + $x = 0; + while (false !== ($file = readdir($dir_list))) { + if ($file != "." AND $file != ".."){ + $new_path = $dir.'/'.$file; + $level = explode('/',$new_path); + if (in_array(strtolower(pathinfo($new_path, PATHINFO_EXTENSION)), $image_extensions)) { + $v_background_array[] = $new_path; + } + if ($x > 100) { break; }; + $x++; + } + } + if ($_SESSION['background_image'] == '' && sizeof($v_background_array) > 0) { + $_SESSION['background_image'] = PROJECT_PATH.$source_path.$v_background_array[array_rand($v_background_array, 1)]; + } + } + else { + $_SESSION['background_image'] = ''; + } + + } + else if ($image_source == 'file') { + $_SESSION['background_image'] = $source_path; } //show the background - echo "
\n"; + if ($_SESSION['background_image'] != '') { + echo "
\n"; + } + + } + + // check for background color + else if ( + isset($_SESSION['theme']['background_color_1']['text']) || + isset($_SESSION['theme']['background_color_2']['text']) + ) { // background color 1 or 2 is enabled + + echo "bg1 = ".$_SESSION['theme']['background_color_1']['text']."

"; + echo "bg2 = ".$_SESSION['theme']['background_color_2']['text']."

"; + + if ($_SESSION['theme']['background_color_1']['text'] != '' && $_SESSION['theme']['background_color_2']['text'] == '') { // use color 1 + echo "
 
\n"; + } + else if ($_SESSION['theme']['background_color_1']['text'] == '' && $_SESSION['theme']['background_color_2']['text'] != '') { // use color 2 + echo "
 
\n"; + } + else if ($_SESSION['theme']['background_color_1']['text'] != '' && $_SESSION['theme']['background_color_2']['text'] != '') { // vertical gradient + echo "
 
\n"; + } + else { // default: white + echo "
 
\n"; + } } ?>