1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* @font-face plugin.
|
6 |
|
|
*/
|
7 |
|
|
class sweaver_plugin_fontface extends sweaver_plugin {
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Sweaver dependencies.
|
11 |
|
|
*/
|
12 |
|
|
public function sweaver_dependencies() {
|
13 |
|
|
return array('fontyourface');
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Sweaver objects alter.
|
18 |
|
|
*/
|
19 |
|
|
public function sweaver_objects_alter(&$objects) {
|
20 |
|
|
$extra_fonts = array();
|
21 |
|
|
$used_fonts = fontyourface_get_fonts('enabled = 1');
|
22 |
|
|
|
23 |
|
|
foreach ($used_fonts as $font) {
|
24 |
|
|
if (module_exists($font->provider)) {
|
25 |
|
|
|
26 |
|
|
if (function_exists('fontyourface_font_css')) {
|
27 |
|
|
$extra_fonts[$font->css_family] = $font->name;
|
28 |
|
|
}
|
29 |
|
|
else {
|
30 |
|
|
$css_function = $font->provider . '_fontyourface_css';
|
31 |
|
|
$font_css = $css_function($font);
|
32 |
|
|
$extra_fonts[$font_css['font-family']] = $font->group_name;
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
// Unserialize first, serialize after.
|
38 |
|
|
if (!is_array($objects->property->all['font-family']->property_options)) {
|
39 |
|
|
$objects->property->all['font-family']->property_options = unserialize($objects->property->all['font-family']->property_options);
|
40 |
|
|
}
|
41 |
|
|
$objects->property->all['font-family']->property_options += $extra_fonts;
|
42 |
|
|
$objects->property->all['font-family']->property_options = serialize($objects->property->all['font-family']->property_options);
|
43 |
|
|
if (isset($objects->property->enabled['font-family'])) {
|
44 |
|
|
if (!is_array($objects->property->all['font-family']->property_options)) {
|
45 |
|
|
$objects->property->enabled['font-family']->property_options = unserialize($objects->property->enabled['font-family']->property_options);
|
46 |
|
|
}
|
47 |
|
|
$objects->property->enabled['font-family']->property_options += $extra_fonts;
|
48 |
|
|
$objects->property->enabled['font-family']->property_options = serialize($objects->property->enabled['font-family']->property_options);
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
}
|