style.php 4.91 KB
Newer Older
1 2 3 4 5 6
<?php
/**
 *
 * @package    mahara
 * @subpackage skin
 * @author     Gregor Anzelj
7 8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
9 10 11 12 13 14 15 16 17 18
 * @copyright  (C) 2010-2013 Gregor Anzelj <gregor.anzelj@gmail.com>
 *
 */

define('INTERNAL', 1);
define('PUBLIC', 1);
define('NOCHECKPASSWORDCHANGE', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('skin.php');

19 20 21
if (!get_config('skins')) {
    throw new FeatureNotEnabledException();
}
22 23 24 25 26 27 28 29 30 31

$id = param_integer('skin', 0);
if ($id == 0) {
    echo '';
    exit;
}

$viewid = param_integer('view', null);

$skin = get_record('skin', 'id', $id);
32 33 34 35
$skinobj = new Skin($id);
if (!$skinobj->can_view()) {
    throw new AccessDeniedException();
}
36
$skin->viewskin = unserialize($skin->viewskin);
37
foreach ($skin->viewskin as $key => $option) {
38
    if ($option === 'transparent') {
39 40 41
        $skin->viewskin[$key] = '';
    }
}
42
$smarty = smarty();
43 44

// Font Notice
45 46
$smarty->assign('view_text_font_notice', Skin::get_css_font_notice_from_font_name($skin->viewskin['view_text_font_family']));
$smarty->assign('view_heading_font_notice', Skin::get_css_font_notice_from_font_name($skin->viewskin['view_heading_font_family']));
47 48

// BODY
49
$smarty->assign('body_background_color', $skin->viewskin['body_background_color']);
50
if (empty($skin->viewskin['body_background_image']) || $skin->viewskin['body_background_image'] == null) {
51
    $body_background_image = '';
52 53 54 55 56 57 58 59
}
else {
    $body_background_image = 'url(\'' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $skin->viewskin['body_background_image'];
    if ($viewid) {
        $body_background_image .= "&view={$viewid}";
    }
    $body_background_image .= '\')';
}
60
$smarty->assign('body_background_image', $body_background_image);
61 62 63
$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']) : '');
64 65

// HEADER
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
$smarty->assign('header_background_color', $skin->viewskin['header_background_color']);

if (empty($skin->viewskin['header_background_image'])) {
    $header_background_image = '';
}
else {
    $header_background_image = 'url(\'' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $skin->viewskin['header_background_image'];
    if ($viewid) {
        $header_background_image .= "&view={$viewid}";
    }
    $header_background_image .= '\')';
}

$smarty->assign('header_background_image', $header_background_image);

81
// TEXT
82
$smarty->assign('view_text_font_face', Skin::get_css_font_face_from_font_name($skin->viewskin['view_text_font_family']));
83
$smarty->assign('view_text_font_family', Skin::get_css_font_family_from_font_name($skin->viewskin['view_text_font_family'], 'text'));
84
$smarty->assign('tabs_height', Skin::get_tabs_height_from_font_name($skin->viewskin['view_text_font_family']));  // TODO remove this
85
$smarty->assign('view_heading_font_face', Skin::get_css_font_face_from_font_name($skin->viewskin['view_heading_font_family']));
86
$smarty->assign('view_heading_font_family', Skin::get_css_font_family_from_font_name($skin->viewskin['view_heading_font_family'], 'heading'));
87 88 89 90
$smarty->assign('view_text_font_size', $skin->viewskin['view_text_font_size']);
$smarty->assign('view_text_font_color', $skin->viewskin['view_text_font_color']);
$smarty->assign('view_text_heading_color', $skin->viewskin['view_text_heading_color']);
$smarty->assign('view_text_emphasized_color', $skin->viewskin['view_text_emphasized_color']);
91 92

// LINK
93 94 95 96
$smarty->assign('view_link_normal_color', $skin->viewskin['view_link_normal_color']);
$smarty->assign('view_link_normal_underline', ($skin->viewskin['view_link_normal_underline'] == true ? 'underline' : 'none'));
$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'));
97 98

// ADVANCED
99
$smarty->assign('view_custom_css', $skin->viewskin['view_custom_css']);
100 101


102 103 104 105 106 107 108 109
// Set no caching for thumbnails...
// Never use Expires = 0 to prevent caching!
// See: http://docs.oracle.com/cd/E13158_01/alui/wci/docs103/devguide/tsk_pagelets_settingcaching_httpexpires.html
header("Expires: Tue, 10 Nov 2009 00:00:00 GMT");  // Date in the past - Mahara project registered at Launchpad.net
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
110
header('Content-type: text/css');
111
echo $smarty->fetch('skin/style.tpl');
112
exit;