function fontyourface_admin_edit_form in @font-your-face 6.2
Same name and namespace in other branches
- 6 fontyourface.module \fontyourface_admin_edit_form()
- 7 fontyourface.module \fontyourface_admin_edit_form()
Edit form changes a single font, including CSS selector and enabled status.
2 string references to 'fontyourface_admin_edit_form'
- fontyourface_menu in ./
fontyourface.module - Implements hook_menu().
- local_fonts_form_alter in modules/
local_fonts/ local_fonts.module - Implementation of hook_form_alter().
File
- ./
fontyourface.module, line 571
Code
function fontyourface_admin_edit_form(&$form_state, $fid) {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l('@font-your-face', 'admin/build/themes/fontyourface');
drupal_set_breadcrumb($breadcrumb);
drupal_add_js(drupal_get_path('module', 'fontyourface') . '/js/add_form.js');
$font = fontyourface_get_font($fid);
$info_function = $font->provider . '_fontyourface_info';
if (function_exists($info_function)) {
$provider = $info_function();
}
// if
if (count($font->tags) > 0) {
$tags = implode(', ', $font->tags);
}
else {
$tags = '<i>No tags</i>';
}
// else
$form = array(
'fid' => array(
'#type' => 'value',
'#value' => $font->fid,
),
'details' => array(
'#type' => 'fieldset',
'#title' => t('Details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'font' => array(
'#value' => '<div class="font">' . t('Font: !font', array(
'!font' => l($font->name, $font->url),
)) . '</div>',
),
'provider' => array(
'#value' => '<div class="provider">' . t('Provider: !provider', array(
'!provider' => l($provider['name'], $provider['url']),
)) . '</div>',
),
'tags' => array(
'#value' => '<div class="tags">' . t('Tags: !tags', array(
'!tags' => $tags,
)) . '</div>',
),
),
);
if ($font->foundry != '') {
if ($font->foundry_url != '') {
$foundry_markup = l($font->foundry, $font->foundry_url);
}
else {
$foundry_markup = check_plain($font->foundry);
}
// else
$form['details'] += array(
'foundry' => array(
'#value' => '<div class="foundry">' . t('Foundry: !foundry', array(
'!foundry' => $foundry_markup,
)) . '</div>',
),
);
}
// if
if ($font->license != '') {
if ($font->license_url != '') {
$license_markup = l($font->license, $font->license_url, array(
'attributes' => array(
'rel' => 'license',
),
));
}
else {
$license_markup = check_plain($font->license);
}
// else
$form['details'] += array(
'license' => array(
'#value' => '<div class="license">' . t('License: !license', array(
'!license' => $license_markup,
)) . '</div>',
),
);
}
// if
$view = '';
$view_function = $font->provider . '_fontyourface_view';
if (function_exists($view_function)) {
$view = $view_function($font, variable_get('fontyourface_sample_text', 'The quick brown fox jumps over the lazy dog'));
}
// if
$form += array(
'preview' => array(
'#type' => 'fieldset',
'#title' => t('Preview'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'sample_text' => array(
'#type' => 'textfield',
'#title' => t('Sample text'),
'#default_value' => variable_get('fontyourface_sample_text', 'The quick brown fox jumps over the lazy dog'),
'#size' => 60,
),
'font_view' => array(
'#value' => '<div class="fontyourface-view">' . $view . '</div>',
),
),
'css' => array(
'#type' => 'textarea',
'#title' => t('CSS selector'),
'#default_value' => $font->css_selector,
'#description' => t('Use commas to separate multiple selectors, just like you would in CSS. Leave blank to handle application of the font in your theme.'),
),
);
if ($font->css_family != '') {
$form += array(
'font-family' => array(
'#value' => '<div>' . t('To apply in your own CSS, use:') . '</div><div><code>font-family: ' . check_plain($font->css_family) . ';</code></div>',
),
);
}
// if
$form += array(
'enabled' => array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => $font->enabled,
),
'buttons' => array(
'submit' => array(
'#type' => 'submit',
'#value' => t('Save font settings'),
),
'cancel' => array(
'#type' => 'submit',
'#value' => t('Cancel changes'),
),
),
);
return $form;
}