function fontyourface_preprocess_page in @font-your-face 6
Same name and namespace in other branches
- 6.2 fontyourface.module \fontyourface_preprocess_page()
- 7 fontyourface.module \fontyourface_preprocess_page()
Implements template_preprocess_page().
File
- ./
fontyourface.module, line 79
Code
function fontyourface_preprocess_page(&$vars) {
$fonts = array();
$destination = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . file_directory_path() . '/fontyourface/font.css';
$directory = dirname($destination);
if (file_check_directory($directory, FILE_CREATE_DIRECTORY)) {
$font_face = '';
$font_family = '';
if ($_GET['q'] == 'admin/build/themes/fontyourface/add') {
$available_fonts = fontyourface_available_fonts();
foreach ($available_fonts as $module_name => $module_info) {
$font_providers[$module_name] = array();
foreach ($module_info['fonts'] as $group_name => $group_info) {
foreach ($group_info['fonts'] as $font_name => $group_font) {
$font = new stdClass();
$font->provider = $module_name;
$font->group_name = $group_name;
$font->name = $font_name;
$fonts[] = $font;
}
// foreach
}
// foreach
}
// foreach
usort($fonts, 'fontyourface_by_font_name');
$page = isset($_GET['page']) ? intval($_GET['page']) : 0;
$fonts = array_slice($fonts, $page * FONTYOURFACE_ADD_PAGE_COUNT, FONTYOURFACE_ADD_PAGE_COUNT);
}
elseif (strpos($_GET['q'], 'admin/build/themes/fontyourface/add/') === 0) {
$adding_font = fontyourface_get_font_from_path(arg(5), arg(6), arg(7));
if (!$adding_font) {
$module_name = arg(6, $_SERVER['REDIRECT_URL']);
$group_path = arg(7, $_SERVER['REDIRECT_URL']);
$font_path = arg(8, $_SERVER['REDIRECT_URL']);
$adding_font = fontyourface_get_font_from_path($module_name, $group_path, $font_path);
}
// if
if ($adding_font) {
$font = new stdClass();
$font->provider = $adding_font['module'];
$font->group_name = $adding_font['group'];
$font->name = $adding_font['font name'];
$fonts[] = $font;
}
// if
}
// elseif
$used_fonts = fontyourface_get_fonts();
foreach ($used_fonts as $font) {
if (module_exists($font->provider)) {
$css_function = $font->provider . '_fontyourface_css';
$font_css = $css_function($font);
if ($font_css['@font-face'] != '') {
$font_face .= '@font-face { ' . $font_css['@font-face'] . ' }' . "\n";
}
// if
if ($font_css['font-family'] != '' && $font->css != '') {
$font_family .= $font->css . ' { font-family: ' . $font_css['font-family'] . '; }' . "\n";
}
// if
$fonts[] = $font;
}
// if
}
// foreach
$css = $font_face . $font_family;
file_save_data($css, $destination, FILE_EXISTS_REPLACE);
}
// if
if ($css != '') {
fontyourface_add_css_in_preprocess($vars, file_directory_path() . '/fontyourface/font.css');
}
// if
$vars['fontyourface'] = $fonts;
}