function fontsquirrel_fontyourface_import in @font-your-face 7
Same name and namespace in other branches
- 6.2 modules/fontsquirrel/fontsquirrel.module \fontsquirrel_fontyourface_import()
- 7.2 modules/fontsquirrel/fontsquirrel.module \fontsquirrel_fontyourface_import()
Implements hook_fontyourface_import().
File
- modules/
fontsquirrel/ fontsquirrel.module, line 207
Code
function fontsquirrel_fontyourface_import() {
$logging = variable_get('fontyourface_detailed_logging', FALSE);
$api_result = drupal_http_request('http://www.fontsquirrel.com/api/fontlist/all');
if ($api_result->code == '200') {
$decoded = json_decode($api_result->data);
foreach ($decoded as $font_import) {
$metadata = array(
'id' => $font_import->id,
'path' => $font_import->family_urlname,
'font_filename' => $font_import->font_filename,
);
$font = new StdClass();
$font->name = $font_import->family_name;
$font->url = 'http://www.fontsquirrel.com/fonts/' . $font_import->family_urlname;
$font->provider = 'fontsquirrel';
$font->foundry = $font_import->foundry_name;
$font->foundry_url = 'http://www.fontsquirrel.com/foundry/' . $font_import->foundry_urlname;
$font->license = 'See Font Squirrel license page';
$font->license_url = 'http://www.fontsquirrel.com/fonts/' . $font_import->family_urlname . '#eula';
$font->tags = array(
$font_import->classification,
);
$font->metadata = serialize($metadata);
fontyourface_save_font($font);
}
// foreach
}
else {
drupal_set_message(t('There was an error downloading font list from Font Squirrel.'), 'error');
if ($logging) {
watchdog('@font-your-face', 'Invalid drupal_http_request response: @response', array(
'@response' => print_r($response, TRUE),
), WATCHDOG_INFO);
}
// if
}
// else
}