t('Disabled'),
6 => t('Externally load the latest from github (version: @version)', array('@version' => $versions['fontfaceobserver']['remote'])),
);
$description = t('This will use the fallback font until the font has been downloaded. See fontfaceobserver for more info.', array(
'@link' => $library['vendor url'],
));
if (function_exists('libraries_info')) {
if ($library['installed']) {
$options += array(
2 => t('Inline javascript (version: @version)', array('@version' => $library['version'])),
4 => t('Local file included in aggregate (version: @version)', array('@version' => $library['version'])),
);
}
elseif (!is_readable('sites/all/libraries/fontfaceobserver/fontfaceobserver.js')) {
$description .= ' ' . t('To use fontfaceobserver locally fontfaceobserver needs to be placed inside the sites/all/libraries directory so sites/all/libraries/fontfaceobserver/fontfaceobserver.js and package.json can be found at that location.', array(
'@url' => 'https://www.drupal.org/project/libraries',
));
}
else {
$description .= ' ' . t('Go to the library report page and make sure fontfaceobserver is installed correctly.', array(
'@url' => url('admin/reports/libraries'),
));
}
}
elseif (is_readable('sites/all/libraries/fontfaceobserver/fontfaceobserver.js')) {
$description .= ' ' . t('To use fontfaceobserver locally the libraries api module needs to be installed.', array(
'@url' => 'https://www.drupal.org/project/libraries',
));
}
else {
$description .= ' ' . t('To use fontfaceobserver locally the libraries api module needs to be installed and then fontfaceobserver needs to be placed inside the sites/all/libraries directory so sites/all/libraries/fontfaceobserver/fontfaceobserver.js and package.json can be found at that location.', array(
'@url' => 'https://www.drupal.org/project/libraries',
));
}
ksort($options);
$form['advagg_font_fontfaceobserver'] = array(
'#type' => 'radios',
'#title' => t('Use font face observer to load fonts asynchronously.'),
'#default_value' => variable_get('advagg_font_fontfaceobserver', ADVAGG_FONT_FONTFACEOBSERVER),
'#options' => $options,
'#description' => $description,
);
$form['container'] = array(
'#type' => 'container',
'#states' => array(
'invisible' => array(
':input[name="advagg_font_fontfaceobserver"]' => array('value' => '0'),
),
),
);
$form['container']['advagg_font_cookie'] = array(
'#type' => 'checkbox',
'#title' => t('Set a cookie so the flash of unstyled text (FOUT) only happens once.'),
'#default_value' => variable_get('advagg_font_cookie', ADVAGG_FONT_COOKIE),
'#description' => t('Cookies are name like @cookie
. If this is a problem you can disable cookies from being set; if doing so the FOUT will happen on every page load.', array('@cookie' => 'advaggfont_pt-sans=PT Sans')),
);
$form['container']['advagg_font_no_fout'] = array(
'#type' => 'checkbox',
'#title' => t('Prevent the Flash of Unstyled Text.'),
'#default_value' => variable_get('advagg_font_no_fout', ADVAGG_FONT_NO_FOUT),
'#description' => t('The font will not be changed unless the browser already has the font downloaded. Font gets downloaded on the first page view.', array('@cookie' => 'advaggfont_pt-sans=PT Sans')),
'#states' => array(
'disabled' => array(
'#edit-advagg-font-cookie' => array('checked' => FALSE),
),
),
);
// Get all css files and scan for quoted fonts.
$form['fonts'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('CSS files with external fonts'),
);
// Get filename, filename_hash, and changes.
$results = db_select('advagg_files', 'af')
->fields('af', array('filename', 'filename_hash', 'changes'))
->condition('filetype', 'css')
->execute();
while ($row = $results->fetchAssoc()) {
if (!file_exists($row['filename'])) {
continue;
}
// Get the file contents.
$file_contents = (string) @advagg_file_get_contents($row['filename']);
// Get font names.
$replacements = advagg_font_get_replacements_array($file_contents);
if (!empty($replacements)) {
$fonts = array();
foreach ($replacements as $key => $replacement) {
$fonts[$key . ' ' . $replacement[3]] = $replacement[5];
}
$form['fonts'][$row['filename_hash']] = array(
'#markup' => '
@replacements