Commit e9a23d53 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

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

parents 080c6582 683255c3
......@@ -33,7 +33,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"';
......
......@@ -24,8 +24,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"' : '')
......
......@@ -905,9 +905,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) {
......
......@@ -123,6 +123,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,
),
)
)
);
......@@ -193,6 +196,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,
),
)
)
);
......@@ -274,18 +280,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',
......@@ -297,6 +312,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',
......@@ -358,6 +376,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',
......@@ -365,6 +386,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',
......@@ -372,12 +396,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',
......@@ -389,6 +419,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',
......@@ -407,45 +440,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('tableoddrows', '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('tableevenrows', '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,
),
),
),
);
......
......@@ -34,7 +34,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
......@@ -44,7 +48,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'];
......@@ -54,9 +58,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']);
......@@ -69,7 +73,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'];
......@@ -79,9 +83,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};
......@@ -157,7 +161,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 {
......@@ -194,4 +202,4 @@ ul.colnav li a:active {
border: 0 none;
}
/** advanced: custom css **/
{$view_custom_css|safe}
\ No newline at end of file
{$view_custom_css|safe}
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