function textsize_print_html in Text Size 7
Same name and namespace in other branches
- 5 textsize.module \textsize_print_html()
- 6 textsize.module \textsize_print_html()
Print HTMl code in the head.
Return value
CSS HTML code in the head.
1 call to textsize_print_html()
- textsize_page_build in ./
textsize.module - Implement hook_page_build()
File
- ./
textsize.module, line 243 - Display a text size changer on the page for a better web accessibility.
Code
function textsize_print_html() {
$textsize = textsize_get_current($value = 'int');
$textsize_link_type = variable_get('textsize_link_type', 'variable');
$textsize_element = variable_get('textsize_element', 'body');
$textsize_element_class = filter_xss(variable_get('textsize_element_class', ''));
$textsize_element = variable_get('textsize_element', 'body');
$textsize_element_class = filter_xss(variable_get('textsize_element_class', ''));
$textsize_important = " !important";
if (variable_get('textsize_important', 1) == 0) {
$textsize_important = NULL;
}
$ts_in = variable_get('textsize_increment', 6);
$ts_no = variable_get('textsize_normal', 76);
$ts_mi = variable_get('textsize_minimum', 50);
$ts_ma = variable_get('textsize_maximum', 150);
if (is_numeric($ts_in) && is_numeric($ts_no) && is_numeric($ts_mi) && is_numeric($ts_ma)) {
if ($ts_in >= 0.01 && $ts_no >= 0.02 && $ts_mi >= 0.01 && $ts_ma >= 0.03) {
$ts_st = $ts_no - ceil(($ts_no - $ts_mi) / $ts_in) * $ts_in;
$ts_en = $ts_no + floor(($ts_ma - $ts_no) / $ts_in) * $ts_in;
}
}
$textsize_head = $textsize_element . $textsize_element_class . ' {
font-size: ' . $textsize . '%' . $textsize_important . ';
}';
if ($textsize_important == " !important") {
$textsize_head = $textsize_element . $textsize_element_class . ' {
font-size: ' . $textsize . '% ' . $textsize_important . ';
}';
if ($textsize_link_type == 'fix') {
for ($value = $ts_no - $ts_in; $value <= $ts_no + $ts_in; $value = $value + $ts_in) {
$textsize_head .= $textsize_element . '.textsize-' . str_replace('.', '-', round($value, 2)) . ' { font-size: ' . round($value, 2) . '%' . $textsize_important . '; } ';
}
}
elseif ($textsize_link_type == 'variable') {
for ($value = $ts_st; $value <= $ts_en; $value = $value + $ts_in) {
$textsize_head .= $textsize_element . '.textsize-' . str_replace('.', '-', round($value, 2)) . ' { font-size: ' . round($value, 2) . '%' . $textsize_important . '; } ';
}
}
}
// 'media' => 'screen, projection, tty, tv, print'
if (!textsize_admin_theme_check()) {
drupal_add_css($textsize_head, $options = array(
'type' => 'inline',
'media' => 'screen',
));
}
}