Commit 0e0ef413 authored by Robert Lyon's avatar Robert Lyon

Bug 1835869: Remove obsolete skin options

The old options to be removed are:

- header_text_font_color
- header_link_normal_color
- header_link_normal_underline
- header_link_hover_color
- header_link_hover_underline
- header_logo_image
- view_background_color
- view_background_image
- view_background_repeat
- view_background_attachment
- view_background_position
- view_background_width
- view_table_border_color
- view_table_header_color
- view_table_header_text_color
- view_table_odd_row_color
- view_table_even_row_color
- view_button_normal_color
- view_button_hover_color
- view_button_text_color

behatnotneeded

Change-Id: I909e7bcb4f559d9cd052cf4c7b2b80982ecf109c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent ad7250b7
......@@ -66,20 +66,8 @@ class Skin {
'body_background_attachment' => 'scroll',
'body_background_position' => 1,
'header_background_color' => '#DDDDDD', // TODO remove this
'header_text_font_color' => '#000000', // TODO remove this
'header_link_normal_color' => '#000000', // TODO remove this
'header_link_normal_underline' => true, // TODO remove this
'header_link_hover_color' => '#808080', // TODO remove this
'header_link_hover_underline' => true, // TODO remove this
'header_logo_image' => 'normal', // TODO remove this
'view_background_color' => '#FFFFFF', // TODO remove this
'view_background_image' => 0, // TODO remove this
'view_background_repeat' => 4, // TODO remove this
'view_background_attachment' => 'scroll', // TODO remove this
'view_background_position' => 1, // TODO remove this
'view_background_width' => 80, // TODO remove this
'header_background_color' => '#DDDDDD',
'header_background_image' => 0,
'view_text_font_family' => 'Arial',
'view_heading_font_family' => 'Arial',
......@@ -93,16 +81,6 @@ class Skin {
'view_link_hover_color' => '##551A8B',
'view_link_hover_underline' => true,
'view_table_border_color' => '#CCCCCC', // TODO remove this
'view_table_header_color' => '#CCCCCC', // TODO remove this
'view_table_header_text_color' => '#000000', // TODO remove this
'view_table_odd_row_color' => '#EEEEEE', // TODO remove this
'view_table_even_row_color' => '#FFFFFF', // TODO remove this
'view_button_normal_color' => '#DDDDDD', // TODO remove this
'view_button_hover_color' => '#CCCCCC', // TODO remove this
'view_button_text_color' => '#000000', // TODO remove this
'view_custom_css' => '',
);
......@@ -975,7 +953,7 @@ class Skin {
}
// ========== BODY BACKGROUND IMAGE ==========
if ($skin['body_background_image'] <> null) {
if (!empty($skin['body_background_image'])) {
require_once(get_config('docroot') . 'artefact/file/lib.php');
$fileid = $skin['body_background_image'];
$fileobj = artefact_instance_from_id($fileid);
......@@ -999,49 +977,18 @@ class Skin {
self::imagebackgroundfill($img, $bodybackgroundfill, Skin::PREVIEW_THUMBNAIL_ZOOM, intval($skin['body_background_repeat']), intval($skin['body_background_position']));
}
// ========== VIEW BACKGROUND COLOR ========== // TODO remove this
$viewwidth = Skin::PREVIEW_WIDTH-intval(((100 - $skin['view_background_width']) / 100) * Skin::PREVIEW_WIDTH);
// ========== VIEW BACKGROUND COLOR ==========
$viewwidth = Skin::PREVIEW_WIDTH - intval(0.2 * Skin::PREVIEW_WIDTH);
$viewheight = Skin::PREVIEW_HEIGHT;
$img2 = imagecreatetruecolor($viewwidth*Skin::PREVIEW_THUMBNAIL_ZOOM+1, $viewheight*Skin::PREVIEW_THUMBNAIL_ZOOM);
$img2 = imagecreatetruecolor($viewwidth * Skin::PREVIEW_THUMBNAIL_ZOOM + 1, $viewheight * Skin::PREVIEW_THUMBNAIL_ZOOM);
// Turn off alpha blending and set alpha flag
imagealphablending($img2, true);
imagesavealpha($img2, true);
if ($skin['view_background_color'] <> 'transparent') {
list($r, $g, $b) = self::get_rgb_from_hex($skin['view_background_color']);
$viewbackgroundcolor = imagecolorallocate($img2, $r, $g, $b);
imagefill($img2, 0, 0, $viewbackgroundcolor);
}
else {
$transparentcolor = imagecolorallocatealpha($img2, 255, 255, 255, 127);
imagefill($img2, 0, 0, $transparentcolor);
}
/* ========== VIEW BACKGROUND IMAGE ========== */ // TODO remove this
if ($skin['view_background_image'] <> null) {
require_once(get_config('docroot') . 'artefact/file/lib.php');
$fileid = $skin['view_background_image'];
$fileobj = artefact_instance_from_id($fileid);
$filetype = $fileobj->get('filetype');
switch ($filetype) {
case "image/gif":
$viewbackgroundfill = imagecreatefromgif($fileobj->get_path());
break;
case "image/jpeg":
$viewbackgroundfill = imagecreatefromjpeg($fileobj->get_path());
break;
case "image/png":
default:
$viewbackgroundfill = imagecreatefrompng($fileobj->get_path());
break;
}
imagealphablending($viewbackgroundfill, false);
imagesavealpha($viewbackgroundfill, true);
self::imagebackgroundfill($img2, $viewbackgroundfill, Skin::PREVIEW_THUMBNAIL_ZOOM, intval($skin['view_background_repeat']), intval($skin['view_background_position']));
}
list($r, $g, $b) = self::get_rgb_from_hex('#FFFFFF');
$viewbackgroundcolor1 = imagecolorallocatealpha($img2, $r, $g, $b, 127);
imagefill($img2, 0, 0, $viewbackgroundcolor1);
// ========== SAMPLE HEADING BACKGROUND IMAGE/COLOUR AND TEXT ==========
......@@ -1060,24 +1007,23 @@ class Skin {
list($r, $g, $b) = self::get_rgb_from_hex($skin['header_background_color']);
$heading_background_color = imagecolorallocate($img, $r, $g, $b);
$headerwidth = Skin::PREVIEW_WIDTH - intval(((100 - $skin['view_background_width']) / 100) * Skin::PREVIEW_WIDTH);
$headerheight = $heading_size ;
$headerwidth = Skin::PREVIEW_WIDTH - intval(0.2 * Skin::PREVIEW_WIDTH);
$headerheight = $heading_size;
list($r, $g, $b) = self::get_rgb_from_hex('#FFFFFF');
$viewbackgroundcolor2 = imagecolorallocate($img2, $r, $g, $b);
imagefilledrectangle($img2, 0, $headerheight + ($header_font_size * 2.5) + 1, $viewwidth, $viewheight, $viewbackgroundcolor2);
// Draw header background colour block on the VIEW and BODY
imagefilledrectangle($img, 0, 0, $headerwidth, $headerheight + ($header_font_size * 2.5), $heading_background_color);
imagefilledrectangle($img2, 0, 0, $headerwidth, $headerheight + ($header_font_size * 2.5), $heading_background_color);
// Replace header colour with sample header image if there is one allocated
$imagewidth = 0; // @TODO need to stretch the thumbnail if image with for header is less than headerwidth
if (isset($skin['header_background_image']) && $skin['header_background_image'] != null) {
if (!empty($skin['header_background_image'])) {
require_once(get_config('docroot') . 'artefact/file/lib.php');
$fileid = $skin['header_background_image'];
$fileobj = artefact_instance_from_id($fileid);
$filetype = $fileobj->get('filetype');
$image = new ArtefactTypeImage($fileid);
$imagewidth = $image->get('width');
switch ($filetype) {
case "image/gif":
$headerimage = imagecreatefromgif($fileobj->get_path());
......@@ -1091,9 +1037,10 @@ class Skin {
break;
}
$headerimage = imagescale($headerimage, Skin::PREVIEW_WIDTH);
// Draw header image on the VIEW and BODY
self::imageheaderfill($img, $headerimage, Skin::PREVIEW_THUMBNAIL_ZOOM*1.2, 1, $headerwidth, $headerheight + ($header_font_size * 2.6));
self::imageheaderfill($img2, $headerimage, Skin::PREVIEW_THUMBNAIL_ZOOM*1.2, 1, $headerwidth, $headerheight + ($header_font_size * 2.6), -22);
}
// Even though this text is only used in preview images, it's possible the site might want to change
......@@ -1106,7 +1053,7 @@ class Skin {
list($r, $g, $b) = self::get_rgb_from_hex($skin['view_text_emphasized_color']);
$emphasized_color = imagecolorallocate($img, $r, $g, $b);
list($r, $g, $b) = self::get_rgb_from_hex($skin['view_table_border_color']);
list($r, $g, $b) = self::get_rgb_from_hex('#CCCCCC');
$line_color = imagecolorallocate($img, $r, $g, $b);
$emphasized_text1 = get_string('previewsubhead1', 'skin'); // Latin for text
$emphasized_text2 = get_string('previewsubhead2', 'skin'); // Latin for image
......@@ -1122,7 +1069,7 @@ class Skin {
// Add second column to the preview thumbnail, if the width of the view is greater or equal 70%
// or the size of regular text is less than 8...
if (intval($skin['view_background_width']) >= 70 && $text_size < 8) {
if ($text_size < 8) {
// Add sample picture
$sample_img = imagecreatefrompng($THEME->get_path('images/skin_preview_img.png'));
// Add the sample sub-heading 2 and underline, then merge $sample_img into $img2
......@@ -1146,7 +1093,7 @@ class Skin {
}
// ========== COPY VIEW PART OVER BODY PART OF THE THUMBNAIL ==========
$viewbackgroundmargin = intval(((Skin::PREVIEW_WIDTH - intval(($skin['view_background_width'] / 100) * Skin::PREVIEW_WIDTH)) / 2) * Skin::PREVIEW_THUMBNAIL_ZOOM);
$viewbackgroundmargin = intval(((Skin::PREVIEW_WIDTH - intval(0.8 * Skin::PREVIEW_WIDTH)) / 2) * Skin::PREVIEW_THUMBNAIL_ZOOM);
$VIEWOFFSETX = $viewbackgroundmargin - 1;
$VIEWOFFSETY = 0;
......
......@@ -52,9 +52,9 @@ if ($id > 0) {
$viewskin['body_background_image'] = false;
}
}
if (!empty($viewskin['view_background_image'])) { // TODO remove this
if (!record_exists('artefact', 'id', $viewskin['view_background_image'])) {
$viewskin['view_background_image'] = false;
if (!empty($viewskin['header_background_image'])) {
if (!record_exists('artefact', 'id', $viewskin['header_background_image'])) {
$viewskin['header_background_image'] = false;
}
}
}
......
......@@ -73,35 +73,10 @@ if (!empty($exportskins)) {
$itemnode->setAttribute('background-attachment', $viewskin['body_background_attachment']);
$itemnode->setAttribute('background-position', Skin::background_position_number_to_value($viewskin['body_background_position']));
// Header element... // TODO remove this
// Header element...
$childelement = $xmldoc->createElement('header');
$itemnode = $rootelement->appendChild($childelement);
$itemnode->setAttribute('background-color', $viewskin['header_background_color']);
$itemnode->setAttribute('font-color', $viewskin['header_text_font_color']);
$itemnode->setAttribute('normal-color', $viewskin['header_link_normal_color']);
if (intval($viewskin['header_link_normal_underline']) == 0) {
$itemnode->setAttribute('normal-decoration', 'none');
}
else {
$itemnode->setAttribute('normal-decoration', 'underline');
}
$itemnode->setAttribute('hover-color', $viewskin['header_link_hover_color']);
if (intval($viewskin['header_link_hover_underline']) == 0) {
$itemnode->setAttribute('hover-decoration', 'none');
}
else {
$itemnode->setAttribute('hover-decoration', 'underline');
}
$itemnode->setAttribute('logo-image', $viewskin['header_logo_image']);
// View (page) element... // TODO remove this
$childelement = $xmldoc->createElement('view');
$itemnode = $rootelement->appendChild($childelement);
$itemnode->setAttribute('background-color', $viewskin['view_background_color']);
$itemnode->setAttribute('background-repeat', Skin::background_repeat_number_to_value($viewskin['view_background_repeat']));
$itemnode->setAttribute('background-attachment', $viewskin['view_background_attachment']);
$itemnode->setAttribute('background-position', Skin::background_position_number_to_value($viewskin['view_background_position']));
$itemnode->setAttribute('width', $viewskin['view_background_width'].'%');
// Text element...
$childelement = $xmldoc->createElement('text');
......@@ -131,13 +106,6 @@ if (!empty($exportskins)) {
$itemnode->setAttribute('hover-decoration', 'underline');
}
// Table element... // TODO remove this
$childelement = $xmldoc->createElement('table');
$itemnode = $rootelement->appendChild($childelement);
$itemnode->setAttribute('border-color', $viewskin['view_table_border_color']);
$itemnode->setAttribute('odd-row-color', $viewskin['view_table_odd_row_color']);
$itemnode->setAttribute('even-row-color', $viewskin['view_table_even_row_color']);
// Skin background image element...
$bodybg = $viewskin['body_background_image'];
if (!empty($bodybg) && $bodybg > 0) {
......@@ -165,33 +133,6 @@ if (!empty($exportskins)) {
}
}
// Page background image element... // TODO remove this
$viewbg = $viewskin['view_background_image'];
if (!empty($viewbg) && $viewbg > 0) {
// Get existing page background image data...
// Get existing skin background image data...
$artefactobj = new ArtefactTypeImage($viewbg);
if ($USER->can_view_artefact($artefactobj)) {
$artefact = get_record('artefact', 'id', $viewbg, null, null, null, null, 'artefacttype,title,description,note');
$artefactfilefiles = get_record('artefact_file_files', 'artefact', $viewbg);
$artefactfileimage = get_record('artefact_file_image', 'artefact', $viewbg);
// Open and read the contents of each file...
$viewbgimage = $artefactobj->get_path();
$fp = fopen($viewbgimage, 'rb');
$filesize = filesize($viewbgimage);
$contents = fread($fp, $filesize);
fclose($fp);
// Export each file...
$childelement = $xmldoc->createElement('image');
$itemnode = $rootelement->appendChild($childelement);
$itemnode->setAttribute('type', 'view-background-image');
$itemnode->setAttribute('artefact', serialize($artefact));
$itemnode->setAttribute('artefact_file_files', serialize($artefactfilefiles));
$itemnode->setAttribute('artefact_file_image', serialize($artefactfileimage));
$itemnode->setAttribute('contents', base64_encode($contents));
}
}
// Fonts element...
// for exporting site fonts, which get embedded via @font-face CSS rule...
$textfonttype = get_field('skin_fonts', 'fonttype', 'name', $viewskin['view_text_font_family']);
......
......@@ -125,38 +125,11 @@ function importskinform_submit(Pieform $form, $values) {
$skin = array_merge($skin, array('body_background_position' => Skin::background_position_value_to_number($item->getAttribute('background-position'))));
}
// Header element... // TODO remove this
// Header element...
$items = $skindata->getElementsByTagName('header');
foreach ($items as $item) {
$skin = array_merge($skin, array('header_background_color' => $item->getAttribute('background-color')));
$skin = array_merge($skin, array('header_text_font_color' => $item->getAttribute('font-color')));
$skin = array_merge($skin, array('header_link_normal_color' => $item->getAttribute('normal-color')));
if ($item->getAttribute('normal-decoration') == 'none') {
$skin = array_merge($skin, array('header_link_normal_underline' => 0));
}
else {
$skin = array_merge($skin, array('header_link_normal_underline' => 1));
}
$skin = array_merge($skin, array('header_link_hover_color' => $item->getAttribute('hover-color')));
if ($item->getAttribute('hover-decoration') == 'none') {
$skin = array_merge($skin, array('header_link_hover_underline' => 0));
}
else {
$skin = array_merge($skin, array('header_link_hover_underline' => 1));
}
$skin = array_merge($skin, array('header_logo_image' => $item->getAttribute('logo-image')));
}
// View element... // TODO remove this
$items = $skindata->getElementsByTagName('view');
foreach ($items as $item) {
$skin = array_merge($skin, array('view_background_color' => $item->getAttribute('background-color')));
$skin = array_merge($skin, array('view_background_image' => 0));
$skin = array_merge($skin, array('view_background_repeat' => Skin::background_repeat_value_to_number($item->getAttribute('background-repeat'))));
$skin = array_merge($skin, array('view_background_attachment' => $item->getAttribute('background-attachment')));
$skin = array_merge($skin, array('view_background_position' => Skin::background_position_value_to_number($item->getAttribute('background-position'))));
$skin = array_merge($skin, array('view_background_width' => str_replace("%", "", $item->getAttribute('width')))); // odstrani znak %!
$skin = array_merge($skin, array('view_background_margin' => $item->getAttribute('margin-top')));
$skin = array_merge($skin, array('header_background_image' => 0));
}
// Text element...
......@@ -189,14 +162,6 @@ function importskinform_submit(Pieform $form, $values) {
}
}
// Table element... // TODO remove this
$items = $skindata->getElementsByTagName('table');
foreach ($items as $item) {
$skin = array_merge($skin, array('view_table_border_color' => $item->getAttribute('border-color')));
$skin = array_merge($skin, array('view_table_odd_row_color' => $item->getAttribute('odd-row-color')));
$skin = array_merge($skin, array('view_table_even_row_color' => $item->getAttribute('even-row-color')));
}
// Custom CSS element...
$items = $skindata->getElementsByTagName('customcss');
foreach ($items as $item) {
......@@ -213,7 +178,7 @@ function importskinform_submit(Pieform $form, $values) {
// TODO: Background image file support for site skins
if ($siteskin) {
$skin['body_background_image'] = 0;
$skin['view_background_image'] = 0;
$skin['header_background_image'] = 0;
}
else {
$items = $skindata->getElementsByTagName('image');
......@@ -275,8 +240,8 @@ function importskinform_submit(Pieform $form, $values) {
if ($type == 'body-background-image') {
$skin['body_background_image'] = $id;
}
if ($type == 'view-background-image') { // TODO remove this
$skin['view_background_image'] = $id;
if ($type == 'header-background-image') {
$skin['header_background_image'] = $id;
}
}
}
......
......@@ -78,30 +78,6 @@ else {
$smarty->assign('header_background_image', $header_background_image);
$smarty->assign('header_text_font_color', $skin->viewskin['header_text_font_color']); // TODO remove this
$smarty->assign('header_link_normal_color', $skin->viewskin['header_link_normal_color']); // TODO remove this
$smarty->assign('header_link_normal_underline', ($skin->viewskin['header_link_normal_underline'] == true ? 'underline' : 'none')); // TODO remove this
$smarty->assign('header_link_hover_color', $skin->viewskin['header_link_hover_color']); // TODO remove this
$smarty->assign('header_link_hover_underline', ($skin->viewskin['header_link_hover_underline'] == true ? 'underline' : 'none')); // TODO remove this
// VIEW
$smarty->assign('view_background_color', $skin->viewskin['view_background_color']); // TODO remove this
if (empty($skin->viewskin['view_background_image']) || $skin->viewskin['view_background_image'] == null) { // TODO remove this
$view_background_image = '';
}
else {
$view_background_image = 'url(\'' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $skin->viewskin['view_background_image'];
if ($viewid) {
$view_background_image .= "&view={$viewid}";
}
$view_background_image .= '\')';
}
$smarty->assign('view_background_image', $view_background_image); // TODO remove this
$smarty->assign('view_background_repeat', (!empty($view_background_image)) ? Skin::background_repeat_number_to_value($skin->viewskin['view_background_repeat']) : ''); // TODO remove this
$smarty->assign('view_background_attachment', (!empty($view_background_image)) ? $skin->viewskin['view_background_attachment'] : ''); // TODO remove this
$smarty->assign('view_background_position', (!empty($view_background_image)) ? Skin::background_position_number_to_value($skin->viewskin['view_background_position']) : ''); // TODO remove this
$smarty->assign('view_background_width', $skin->viewskin['view_background_width'].'%'); // TODO remove this
// TEXT
$smarty->assign('view_text_font_face', Skin::get_css_font_face_from_font_name($skin->viewskin['view_text_font_family']));
$smarty->assign('view_text_font_family', Skin::get_css_font_family_from_font_name($skin->viewskin['view_text_font_family'], 'text'));
......@@ -119,18 +95,6 @@ $smarty->assign('view_link_normal_underline', ($skin->viewskin['view_link_normal
$smarty->assign('view_link_hover_color', $skin->viewskin['view_link_hover_color']);
$smarty->assign('view_link_hover_underline', ($skin->viewskin['view_link_hover_underline'] == true ? 'underline' : 'none'));
// TABLE
$smarty->assign('view_table_border_color', $skin->viewskin['view_table_border_color']); // TODO remove this
$smarty->assign('view_table_header_color', $skin->viewskin['view_table_header_color']); // TODO remove this
$smarty->assign('view_table_header_text_color', $skin->viewskin['view_table_header_text_color']); // TODO remove this
$smarty->assign('view_table_odd_row_color', $skin->viewskin['view_table_odd_row_color']); // TODO remove this
$smarty->assign('view_table_even_row_color', $skin->viewskin['view_table_even_row_color']); // TODO remove this
// BUTTON
$smarty->assign('view_button_normal_color', $skin->viewskin['view_button_normal_color']); // TODO remove this
$smarty->assign('view_button_hover_color', $skin->viewskin['view_button_hover_color']); // TODO remove this
$smarty->assign('view_button_text_color', $skin->viewskin['view_button_text_color']); // TODO remove this
// ADVANCED
$smarty->assign('view_custom_css', $skin->viewskin['view_custom_css']);
......
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