function fontyourface_admin_add_page in @font-your-face 6
Add page shows available fonts.
1 string reference to 'fontyourface_admin_add_page'
- fontyourface_menu in ./
fontyourface.module - Implements hook_menu().
File
- ./
fontyourface.module, line 227
Code
function fontyourface_admin_add_page() {
global $pager_page_array, $pager_total;
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l('@font-your-face', 'admin/build/themes/fontyourface');
drupal_set_breadcrumb($breadcrumb);
$page = isset($_GET['page']) ? $_GET['page'] : '';
$pager_page_array = explode(',', $page);
$available_fonts = fontyourface_available_fonts();
$fonts = array();
$fonts_by_module = array();
foreach ($available_fonts as $module_name => $module_info) {
$fonts_by_module[$module_name] = array();
foreach ($module_info['fonts'] as $group_name => $group_info) {
foreach ($group_info['fonts'] as $font_name => $group_font) {
$fonts_by_module[$module_name][] = $group_font;
$fonts[] = array(
'module' => $module_name,
'provider' => $module_info['name'],
'provider url' => $module_info['url'],
'group' => $group_name,
'group path' => $group_info['path'],
'font name' => $font_name,
'font' => $group_font,
);
}
// foreach
}
// foreach
}
// foreach
$header = array(
t('Name'),
t('Sample'),
t('Provider'),
t('Group'),
);
if (count($fonts) > 0) {
usort($fonts, 'fontyourface_by_font_name');
$pager_total[] = ceil(count($fonts) / FONTYOURFACE_ADD_PAGE_COUNT);
$page = isset($_GET['page']) ? intval($_GET['page']) : 0;
$page_fonts = array_slice($fonts, $page * FONTYOURFACE_ADD_PAGE_COUNT, FONTYOURFACE_ADD_PAGE_COUNT);
foreach ($page_fonts as $font) {
$preview = $font['module'] . '_fontyourface_preview';
$view_link = l($font['font name'], 'admin/build/themes/fontyourface/add/' . $font['module'] . '/' . $font['group path'] . '/' . $font['font']['path']);
$rows[] = array(
$view_link,
$preview($font['font']),
l($font['provider'], $font['provider url']),
check_plain($font['group']),
);
}
// foreach
}
else {
$rows[] = array(
array(
'data' => t('No fonts available. ') . l(t('Enable font providers'), 'admin/build/modules') . ' ' . t('to make fonts available.'),
'colspan' => '4',
),
);
}
// else
return '<h1>Add font</h1><div>Click a font name to view details and add the font.</div>' . theme('table', $header, $rows, array(
'id' => 'font-your-face-options',
)) . theme('pager', NULL, FONTYOURFACE_ADD_PAGE_COUNT);
}