function fontdeck_fontyourface_import in @font-your-face 7
Same name and namespace in other branches
- 6.2 modules/fontdeck/fontdeck.module \fontdeck_fontyourface_import()
- 7.2 modules/fontdeck/fontdeck.module \fontdeck_fontyourface_import()
Implements hook_fontyourface_import().
File
- modules/
fontdeck/ fontdeck.module, line 22
Code
function fontdeck_fontyourface_import() {
$project = variable_get('fontdeck_project', '');
$domain = preg_replace('#^www.#', '', $_SERVER['HTTP_HOST']);
$project_info_url = FONTDECK_BASE_URL . '/project-info?project=' . $project . '&domain=' . $domain;
if ($project != '') {
$response = drupal_http_request($project_info_url);
if ($response->code == 200) {
$data = json_decode($response->data);
$fontdeck_css = variable_get('fontdeck_css', array());
if (!isset($fontdeck_css[$project])) {
$fontdeck_css[$project] = array();
}
// if
$fontdeck_css[$project][$domain] = $data->css;
variable_set('fontdeck_css', $fontdeck_css);
foreach ($data->provides as $import_font) {
$font = new StdClass();
$font->name = $import_font->name;
$font->url = 'http://fontdeck.com/search?q=' . urlencode($import_font->name);
$font->provider = 'fontdeck';
$font->tags = array();
$font->css_family = "'" . $import_font->name . "'";
$font->css_style = $import_font->style;
$font->css_weight = $import_font->weight;
fontyourface_save_font($font);
}
// foreach
}
else {
drupal_set_message(t('There was an error importing font information for project @project on this domain (@domain) from Fontdeck.', array(
'@project' => $project,
'@domain' => $domain,
)), 'error');
}
// else
}
else {
drupal_set_message(t('Missing project number to import.'), 'error');
}
// else
}