Commit 683255c3 authored by Robert Lyon's avatar Robert Lyon

Adding ability to pick no colour with skin elements (bug 1237730)

This way the parent style can be utilised

Have made it so that undefined colours are displayed as ''
eg color: ; as css ignores these lines. (tested in FF and Chrome)

Needed to alter the way body background and view background are
displayed to allow for the inheritance of existing theme css.

I had to split the 'background' css attribute into components eg
background-color, background-image etc because FF was giving colour as
rgb(0, 0 ,0) if misisng from 'background' line.

Change-Id: I404fc87cec1cdd2acc38c495e1dc32095c56bdff
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 8f189300
......@@ -49,7 +49,7 @@ $string['element.expiry.noenddate'] = 'No end date';
$string['element.select.other'] = 'Other';
$string['element.color.or'] = 'or';
$string['element.color.transparent'] = 'Transparent';
$string['element.color.transparent'] = 'Use theme colour';
$string['rule.before.before'] = 'This cannot be after the field "%s"';
......
......@@ -38,8 +38,7 @@ function pieform_element_color(Pieform $form, $element) {
$result = '';
$name = Pieform::hsc($element['name']);
$value = Pieform::hsc($element['defaultvalue']);
$transparent = (!empty($element['options']['transparent']) and $element['options']['transparent'] == true);
$transparent = (!empty($element['options']['transparent']) && $element['options']['transparent'] == true);
// Color Picker (Chooser)
$result = '<input type="text" name="' . $name . '_color" id="' . $name . '_color"'
. ($transparent && !isset($element['defaultvalue']) ? ' disabled="disabled"' : '')
......
......@@ -920,9 +920,15 @@ class Skin {
imagealphablending($img, true);
imagesavealpha($img, true);
list($r, $g, $b) = self::get_rgb_from_hex($skin['body_background_color']);
$bodybackgroundcolor = imagecolorallocate($img, $r, $g, $b);
imagefill($img, 0, 0, $bodybackgroundcolor);
if ($skin['body_background_color'] != 'transparent') {
list($r, $g, $b) = self::get_rgb_from_hex($skin['body_background_color']);
$bodybackgroundcolor = imagecolorallocate($img, $r, $g, $b);
imagefill($img, 0, 0, $bodybackgroundcolor);
}
else {
$transparentcolor = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagefill($img, 0, 0, $transparentcolor);
}
// ========== BODY BACKGROUND IMAGE ==========
if ($skin['body_background_image'] <> null) {
......
......@@ -138,6 +138,9 @@ $elements['skinbg'] = array(
'labelhtml' => get_string('bodybgcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['body_background_color']) ? $viewskin['body_background_color'] : '#FFFFFF'),
'size' => 7,
'options' => array(
'transparent' => true,
),
)
)
);
......@@ -208,6 +211,9 @@ $elements['viewbg'] = array(
'labelhtml' => get_string('viewbgcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_background_color']) ? $viewskin['view_background_color'] : '#FFFFFF'),
'size' => 7,
'options' => array(
'transparent' => true,
),
)
)
);
......@@ -289,18 +295,27 @@ $elements['viewheader'] = array(
'labelhtml' => get_string('backgroundcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['header_background_color']) ? $viewskin['header_background_color'] : '#CCCCCC'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'header_text_font_color' => array(
'type' => 'color',
'labelhtml' => get_string('textcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['header_text_font_color']) ? $viewskin['header_text_font_color'] : '#000000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'header_link_normal_color' => array(
'type' => 'color',
'labelhtml' => get_string('normallinkcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['header_link_normal_color']) ? $viewskin['header_link_normal_color'] : '#0000EE'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'header_link_normal_underline' => array(
'type' => 'checkbox',
......@@ -312,6 +327,9 @@ $elements['viewheader'] = array(
'labelhtml' => get_string('hoverlinkcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['header_link_hover_color']) ? $viewskin['header_link_hover_color'] : '#EE0000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'header_link_hover_underline' => array(
'type' => 'checkbox',
......@@ -373,6 +391,9 @@ $elements['viewcontent'] = array(
'description' => get_string('textcolordescription', 'skin'),
'defaultvalue' => (!empty($viewskin['view_text_font_color']) ? $viewskin['view_text_font_color'] : '#000000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_text_heading_color' => array(
'type' => 'color',
......@@ -380,6 +401,9 @@ $elements['viewcontent'] = array(
'description' => get_string('headingcolordescription', 'skin'),
'defaultvalue' => (!empty($viewskin['view_text_heading_color']) ? $viewskin['view_text_heading_color'] : '#000000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_text_emphasized_color' => array(
'type' => 'color',
......@@ -387,12 +411,18 @@ $elements['viewcontent'] = array(
'description' => get_string('emphasizedcolordescription', 'skin'),
'defaultvalue' => (!empty($viewskin['view_text_emphasized_color']) ? $viewskin['view_text_emphasized_color'] : '#000000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_link_normal_color' => array(
'type' => 'color',
'labelhtml' => get_string('normallinkcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_link_normal_color']) ? $viewskin['view_link_normal_color'] : '#0000EE'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_link_normal_underline' => array(
'type' => 'checkbox',
......@@ -404,6 +434,9 @@ $elements['viewcontent'] = array(
'labelhtml' => get_string('hoverlinkcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_link_hover_color']) ? $viewskin['view_link_hover_color'] : '#EE0000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_link_hover_underline' => array(
'type' => 'checkbox',
......@@ -422,45 +455,69 @@ $elements['viewtable'] = array(
'labelhtml' => get_string('tableborder', 'skin'),
'defaultvalue' => (!empty($viewskin['view_table_border_color']) ? $viewskin['view_table_border_color'] : '#CCCCCC'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_table_header_color' => array(
'type' => 'color',
'labelhtml' => get_string('tableheader', 'skin'),
'defaultvalue' => (!empty($viewskin['view_table_header_color']) ? $viewskin['view_table_header_color'] : '#CCCCCC'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_table_header_text_color' => array(
'type' => 'color',
'labelhtml' => get_string('tableheadertext', 'skin'),
'defaultvalue' => (!empty($viewskin['view_table_header_text_color']) ? $viewskin['view_table_header_text_color'] : '#000000'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_table_odd_row_color' => array(
'type' => 'color',
'labelhtml' => get_string('tableoddlines', 'skin'),
'defaultvalue' => (!empty($viewskin['view_table_odd_row_color']) ? $viewskin['view_table_odd_row_color'] : '#EEEEEE'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_table_even_row_color' => array(
'type' => 'color',
'labelhtml' => get_string('tableevenlines', 'skin'),
'defaultvalue' => (!empty($viewskin['view_table_even_row_color']) ? $viewskin['view_table_even_row_color'] : '#FFFFFF'),
'size' => 7,
'options' => array(
'transparent' => true,
),
),
'view_button_normal_color' => array(
'type' => 'color',
'labelhtml' => get_string('normalbuttoncolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_button_normal_color']) ? $viewskin['view_button_normal_color'] : '#CCCCCC'),
'options' => array(
'transparent' => true,
),
),
'view_button_hover_color' => array(
'type' => 'color',
'labelhtml' => get_string('hoverbuttoncolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_button_hover_color']) ? $viewskin['view_button_hover_color'] : '#EEEEEE'),
'options' => array(
'transparent' => true,
),
),
'view_button_text_color' => array(
'type' => 'color',
'labelhtml' => get_string('buttontextcolor', 'skin'),
'defaultvalue' => (!empty($viewskin['view_button_text_color']) ? $viewskin['view_button_text_color'] : '#FFFFFF'),
'options' => array(
'transparent' => true,
),
),
),
);
......
......@@ -49,7 +49,11 @@ if (!$skinobj->can_view()) {
throw new AccessDeniedException();
}
$skin->viewskin = unserialize($skin->viewskin);
foreach ($skin->viewskin as $key => $option) {
if ($option == 'transparent') {
$skin->viewskin[$key] = '';
}
}
$smarty = smarty();
// Font Notice
......@@ -59,7 +63,7 @@ $smarty->assign('view_heading_font_notice', Skin::get_css_font_notice_from_font_
// BODY
$smarty->assign('body_background_color', $skin->viewskin['body_background_color']);
if (empty($skin->viewskin['body_background_image']) || $skin->viewskin['body_background_image'] == null) {
$body_background_image = 'none';
$body_background_image = '';
}
else {
$body_background_image = 'url(\'' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $skin->viewskin['body_background_image'];
......@@ -69,9 +73,9 @@ else {
$body_background_image .= '\')';
}
$smarty->assign('body_background_image', $body_background_image);
$smarty->assign('body_background_repeat', Skin::background_repeat_number_to_value($skin->viewskin['body_background_repeat']));
$smarty->assign('body_background_attachment', $skin->viewskin['body_background_attachment']);
$smarty->assign('body_background_position', Skin::background_position_number_to_value($skin->viewskin['body_background_position']));
$smarty->assign('body_background_repeat', (!empty($body_background_image)) ? Skin::background_repeat_number_to_value($skin->viewskin['body_background_repeat']) : '');
$smarty->assign('body_background_attachment', (!empty($body_background_image)) ? $skin->viewskin['body_background_attachment'] : '');
$smarty->assign('body_background_position', (!empty($body_background_image)) ? Skin::background_position_number_to_value($skin->viewskin['body_background_position']) : '');
// HEADER
$smarty->assign('header_background_color', $skin->viewskin['header_background_color']);
......@@ -84,7 +88,7 @@ $smarty->assign('header_link_hover_underline', ($skin->viewskin['header_link_hov
// VIEW
$smarty->assign('view_background_color', $skin->viewskin['view_background_color']);
if (empty($skin->viewskin['view_background_image']) || $skin->viewskin['view_background_image'] == null) {
$view_background_image = 'none';
$view_background_image = '';
}
else {
$view_background_image = 'url(\'' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $skin->viewskin['view_background_image'];
......@@ -94,9 +98,9 @@ else {
$view_background_image .= '\')';
}
$smarty->assign('view_background_image', $view_background_image);
$smarty->assign('view_background_repeat', Skin::background_repeat_number_to_value($skin->viewskin['view_background_repeat']));
$smarty->assign('view_background_attachment', $skin->viewskin['view_background_attachment']);
$smarty->assign('view_background_position', Skin::background_position_number_to_value($skin->viewskin['view_background_position']));
$smarty->assign('view_background_repeat', (!empty($view_background_image)) ? Skin::background_repeat_number_to_value($skin->viewskin['view_background_repeat']) : '');
$smarty->assign('view_background_attachment', (!empty($view_background_image)) ? $skin->viewskin['view_background_attachment'] : '');
$smarty->assign('view_background_position', (!empty($view_background_image)) ? Skin::background_position_number_to_value($skin->viewskin['view_background_position']) : '');
$smarty->assign('view_background_width', $skin->viewskin['view_background_width'].'%');
// TEXT
......
......@@ -4,7 +4,11 @@
{$view_heading_font_face|safe}
body,
body#micro {
background: {$body_background_color} {$body_background_image|safe} {$body_background_repeat} {$body_background_attachment} {$body_background_position};
background-color: {$body_background_color};
background-image: {$body_background_image|safe};
background-repeat: {$body_background_repeat};
background-attachment: {$body_background_attachment};
background-position: {$body_background_position};
font-family: {$view_text_font_family|safe};
font-size: {$view_text_font_size};
color: {$view_text_font_color};
......@@ -155,7 +159,11 @@ ul.colnav li a:active {
/* Middle content */
#column-container,
#mainmiddlewrap {
background: {$view_background_color} {$view_background_image|safe} {$view_background_repeat} {$view_background_attachment} {$view_background_position};
background-color: {$view_background_color};
background-image: {$view_background_image|safe};
background-repeat: {$view_background_repeat};
background-attachment: {$view_background_attachment};
background-position: {$view_background_position};
}
/* Blocks */
.blockinstance-header .title {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment