View source
<?php
function fontyourface_permission() {
return array(
'administer @font-your-face' => array(
'title' => t('administer @font-your-face'),
'description' => t('Change which fonts are enabled using the admin interface.'),
),
);
}
function fontyourface_menu() {
$items = array();
$items['admin/config/user-interface/fontyourface'] = array(
'title' => '@font-your-face settings',
'description' => 'Manage font provider accounts and imports.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'fontyourface_settings_form',
),
'access arguments' => array(
'administer @font-your-face',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/appearance/fontyourface'] = array(
'title' => '@font-your-face',
'page callback' => 'fontyourface_admin_page',
'access arguments' => array(
'administer @font-your-face',
),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items['admin/appearance/fontyourface/edit/%'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'fontyourface_admin_edit_form',
4,
),
'access arguments' => array(
'administer @font-your-face',
),
'title callback' => 'fontyourface_admin_edit_form_title',
'title arguments' => array(
4,
),
'type' => MENU_NORMAL_ITEM,
);
$items['fontyourface/autocomplete/tag'] = array(
'title' => 'Autocomplete font tags',
'page callback' => 'fontyourface_autocomplete',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
);
return $items;
}
function fontyourface_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'fontyourface') . '/views',
);
}
function fontyourface_views_pre_render(&$view) {
if ($view->name == 'fontyourface_disabled') {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l('@font-your-face', 'admin/appearance/fontyourface');
drupal_set_breadcrumb($breadcrumb);
$providers = module_implements('fontyourface_info');
if (count($providers) == 0) {
drupal_set_message(t('No font providers enabled. !enable before adding fonts.', array(
'!enable' => l(t('Enable font providers'), 'admin/modules'),
)), 'error');
}
foreach (module_implements('fontyourface_info') as $module) {
$has_fonts = db_query_range("SELECT fid FROM {fontyourface_font} WHERE provider = :provider", 0, 1, array(
':provider' => $module,
))
->fetchObject();
if (!$has_fonts) {
$function = $module . '_fontyourface_info';
$info = $function();
drupal_set_message(t('@provider currently has no fonts. This is probably because the import has not been run yet. !import to add fonts.', array(
'@provider' => $info['name'],
'!import' => l(t('Run import'), 'admin/config/user-interface/fontyourface'),
)), 'error');
}
}
}
}
function fontyourface_views_data() {
$data = array();
$data['fontyourface_font'] = array(
'table' => array(
'group' => t('Font'),
'base' => array(
'field' => 'fid',
'title' => t('Font'),
'help' => t('Fonts from @font-your-face.'),
),
),
'join' => array(
'fontyourface_tag' => array(
'left_table' => 'fontyourface_tag_font',
'left_field' => 'fid',
'field' => 'fid',
),
),
'fid' => array(
'title' => t('Font ID'),
'help' => t('Unique ID for a font.'),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
),
),
'name' => array(
'title' => t('Name'),
'help' => t('Name of the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_font',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'provider' => array(
'title' => t('Provider'),
'help' => t('Module providing the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_provider',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'foundry' => array(
'title' => t('Foundry'),
'help' => t('Foundry of the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_foundry',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'foundry_url' => array(
'title' => t('Foundry URL'),
'help' => t('URL of foundry of the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_foundry',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'license' => array(
'title' => t('License'),
'help' => t('License for using the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_license',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'license_url' => array(
'title' => t('License URL'),
'help' => t('URL of license for using the font.'),
'field' => array(
'handler' => 'views_handler_field_fontyourface_license',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
'enabled' => array(
'title' => t('Enabled'),
'help' => t('Enabled status for a font.'),
'sort' => array(
'handler' => 'views_handler_sort',
),
'field' => array(
'handler' => 'views_handler_field_boolean',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_boolean_operator',
'label' => t('Enabled'),
'type' => 'yes-no',
),
),
'css_family' => array(
'title' => t('CSS font-family'),
'help' => t('CSS font-family attribute.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
);
$data['fontyourface_tag_font'] = array(
'table' => array(
'group' => t('Font'),
'join' => array(
'fontyourface_font' => array(
'left_field' => 'fid',
'field' => 'fid',
),
'fontyourface_tag' => array(
'left_field' => 'tid',
'field' => 'tid',
),
),
),
'tid' => array(
'title' => t('Font Tag'),
'help' => t('Get all tags associated with a font.'),
'field' => array(
'title' => t('All tags'),
'help' => t('Display all tags associated with a font.'),
'handler' => 'views_handler_field_fontyourface_tag_font_tid',
'skip base' => 'fontyourface_tag',
),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'fontyourface_tag',
'base field' => 'tid',
'label' => t('Font Tag'),
),
'filter' => array(
'handler' => 'views_handler_filter_tag_font_tid',
'numeric' => TRUE,
'skip base' => array(
'fontyourface_font',
),
),
),
'fid' => array(
'title' => t('Font'),
'help' => t('Get all fonts associated with a tag.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'fontyourface_font',
'base field' => 'fid',
'label' => t('Font'),
),
),
);
$data['fontyourface_tag'] = array(
'table' => array(
'group' => t('Font'),
'base' => array(
'field' => 'tid',
'title' => t('Font Tag'),
'help' => t('Tags are attached to fonts.'),
),
'join' => array(
'fontyourface_font' => array(
'left_table' => 'fontyourface_tag_font',
'left_field' => 'tid',
'field' => 'tid',
),
'fontyourface_tag_font' => array(
'field' => 'tid',
'left_field' => 'tid',
),
),
),
'tid' => array(
'title' => t('Tag ID'),
'help' => t('A font tag ID'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'skip base' => array(
'fontyourface_font',
),
'zero is null' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_tag_font_tid',
'numeric' => TRUE,
'skip base' => array(
'fontyourface_font',
),
),
),
'name' => array(
'title' => t('Tag'),
'help' => t('A tag attached to a font.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
),
);
return $data;
}
function fontyourface_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'fontyourface') . '/views',
),
'handlers' => array(
'views_handler_field_fontyourface_font' => array(
'parent' => 'views_handler_field',
),
'views_handler_field_fontyourface_provider' => array(
'parent' => 'views_handler_field',
),
'views_handler_field_fontyourface_license' => array(
'parent' => 'views_handler_field',
),
'views_handler_field_fontyourface_foundry' => array(
'parent' => 'views_handler_field',
),
'views_handler_field_fontyourface_tag_font_tid' => array(
'parent' => 'views_handler_field_prerender_list',
),
'views_handler_filter_tag_font_tid' => array(
'parent' => 'views_handler_filter_many_to_one',
),
),
);
}
function fontyourface_settings_form($form, &$form_state) {
$form = array(
'header' => array(
'#markup' => '<div> ' . l(t('Apply fonts under appearance'), 'admin/appearance/fontyourface') . '.</div>',
),
'providers' => array(
'#type' => 'fieldset',
'#title' => 'Providers',
),
'logging' => array(
'#type' => 'fieldset',
'#title' => 'Logging',
'detailed_logs' => array(
'#type' => 'checkbox',
'#default_value' => variable_get('fontyourface_detailed_logging', FALSE),
'#title' => t('Keep detailed watchdog logs'),
'#description' => t("Don't leave this on when testing is complete. It will make everything run a bit slower."),
),
'update' => array(
'#type' => 'submit',
'#value' => t('Change logging settings'),
),
),
);
foreach (module_implements('fontyourface_info') as $module) {
$info_function = $module . '_fontyourface_info';
$provider = $info_function();
$count = db_query("SELECT COUNT(fid) AS total FROM {fontyourface_font} WHERE provider = :provider", array(
':provider' => $module,
))
->fetchObject();
$form['providers'][$module . '_import'] = array(
'#prefix' => '<div>',
'#suffix' => '</div>',
'count' => array(
'#type' => 'item',
'#markup' => t('@provider is enabled with @count fonts.', array(
'@provider' => $provider['name'],
'@count' => $count->total,
)) . ' ',
),
'import' => array(
'#type' => 'submit',
'#value' => 'Import ' . $provider['name'],
),
);
}
return $form;
}
function fontyourface_settings_form_submit($form, &$form_state) {
foreach (module_implements('fontyourface_import') as $module) {
if ($form_state['clicked_button']['#array_parents'][1] == $module . '_import') {
$info_function = $module . '_fontyourface_info';
$provider = $info_function();
$import_function = $module . '_fontyourface_import';
$import_function();
drupal_set_message(t('@provider import complete.', array(
'@provider' => $provider['name'],
)));
}
}
if ($form_state['values']['detailed_logs'] == 1) {
variable_set('fontyourface_detailed_logging', TRUE);
}
else {
variable_set('fontyourface_detailed_logging', FALSE);
}
}
function fontyourface_preprocess_page(&$vars) {
$fonts = fontyourface_font_registry();
$destination = file_build_uri('fontyourface/font.css');
$css = '';
$destination_directory = dirname($destination);
if (file_prepare_directory($destination_directory, FILE_CREATE_DIRECTORY)) {
$enabled_fonts = fontyourface_get_fonts();
foreach ($enabled_fonts as $font) {
$font_css = fontyourface_font_css($font);
if ($font_css != '' && $font->css_selector != '') {
$css .= $font->css_selector . ' { ' . $font_css . ' }' . "\n";
}
$fonts[] = $font;
}
file_unmanaged_save_data($css, $destination, FILE_EXISTS_REPLACE);
}
if ($css != '') {
fontyourface_add_css_in_preprocess($vars, 'fontyourface/font.css');
}
$vars['fontyourface'] = $fonts;
}
function fontyourface_admin_page() {
$view = views_get_view('fontyourface_enabled');
$view
->set_display('block_1');
$output = $view
->preview();
$output .= '<div>' . l('Browse fonts to enable.', 'admin/appearance/fontyourface/add') . '</div>';
return $output;
}
function fontyourface_admin_edit_form_title($fid) {
$font = fontyourface_get_font($fid);
return 'Edit font ' . $font->name;
}
function fontyourface_admin_edit_form($form, &$form_state, $fid) {
drupal_add_js(drupal_get_path('module', 'fontyourface') . '/js/add_form.js');
$font = fontyourface_get_font($fid);
fontyourface_font_registry($font);
$info_function = $font->provider . '_fontyourface_info';
if (function_exists($info_function)) {
$provider = $info_function();
}
$form = array(
'fid' => array(
'#type' => 'hidden',
'#value' => $font->fid,
),
'details' => array(
'#type' => 'fieldset',
'#title' => t('Details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'font' => array(
'#markup' => '<div class="font">' . t('Font: !font', array(
'!font' => l($font->name, $font->url),
)) . '</div>',
),
'provider' => array(
'#markup' => '<div class="provider">' . t('Provider: !provider', array(
'!provider' => l($provider['name'], $provider['url']),
)) . '</div>',
),
'tags' => array(
'#title' => t('Tags'),
'#type' => 'textfield',
'#default_value' => implode(', ', $font->tags),
'#autocomplete_path' => 'fontyourface/autocomplete/tag',
'#maxlength' => 1024,
),
),
);
if ($font->foundry != '') {
if ($font->foundry_url != '') {
$foundry_markup = l($font->foundry, $font->foundry_url);
}
else {
$foundry_markup = check_plain($font->foundry);
}
$form['details'] += array(
'foundry' => array(
'#value' => '<div class="foundry">' . t('Foundry: !foundry', array(
'!foundry' => $foundry_markup,
)) . '</div>',
),
);
}
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);
}
$form['details'] += array(
'license' => array(
'#value' => '<div class="license">' . t('License: !license', array(
'!license' => $license_markup,
)) . '</div>',
),
);
}
$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'));
}
$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(
'#markup' => '<div class="fontyourface-view">' . $view . '</div>',
),
),
'css' => array(
'#type' => 'textarea',
'#title' => t('CSS selector'),
'#resizable' => FALSE,
'#rows' => 3,
'#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>',
),
);
}
$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;
}
function fontyourface_admin_edit_form_submit($form, &$form_state) {
$font = fontyourface_get_font($form['fid']['#value']);
if ($form_state['clicked_button']['#value'] == t('Cancel')) {
drupal_goto('admin/appearance/fontyourface');
}
else {
if ($form['enabled']['#value'] > $font->enabled) {
fontyourface_enable_font($font);
}
elseif ($form['enabled']['#value'] < $font->enabled) {
fontyourface_disable_font($font);
}
if ($font->css_selector != $form['css']['#value']) {
fontyourface_set_css_selector($font, $form['css']['#value']);
}
$tags = drupal_explode_tags($form_state['values']['tags']);
if ($tags != $font->tags) {
db_delete('fontyourface_tag_font')
->condition('fid', $font->fid)
->execute();
fontyourface_add_tags_to_font($tags, $font->fid);
$font->tags = $tags;
fontyourface_delete_unused_tags();
}
drupal_set_message(t('Updated') . ' <i>' . $font->name . '</i>.');
}
}
function fontyourface_autocomplete($tags_typed = '') {
$tags_typed = drupal_explode_tags($tags_typed);
$tag_last = drupal_strtolower(array_pop($tags_typed));
$matches = array();
if ($tag_last != '') {
$query = db_select('fontyourface_tag', 't');
if (!empty($tags_typed)) {
$query
->condition('t.name', $tags_typed, 'NOT IN');
}
$tags_return = $query
->fields('t', array(
'tid',
'name',
))
->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
->range(0, 10)
->execute()
->fetchAllKeyed();
$prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
$matches = array();
foreach ($tags_return as $tid => $name) {
$n = $name;
if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
$n = '"' . str_replace('"', '""', $name) . '"';
}
else {
$matches[$prefix . $n] = check_plain($name);
}
}
}
drupal_json_output($matches);
}
function fontyourface_add_css_in_preprocess(&$vars, $css_path, $type = 'public') {
if ($type == 'remote') {
drupal_add_css($css_path, array(
'type' => 'external',
'group' => CSS_THEME,
));
$vars['styles'] = drupal_get_css();
}
else {
if ($type == 'public') {
$css_path = file_stream_wrapper_get_instance_by_scheme('public')
->getDirectoryPath() . '/' . $css_path;
}
drupal_add_css($css_path, array(
'group' => CSS_THEME,
'basename' => 'fontyourface-' . md5($css_path),
));
$vars['styles'] = drupal_get_css();
}
}
function fontyourface_get_fonts($where = 'enabled = 1', $order_by = 'name ASC') {
$fonts = array();
$results = db_query('SELECT * FROM {fontyourface_font} WHERE ' . $where . ' ORDER BY ' . $order_by);
while ($result = $results
->fetchObject()) {
fontyourface_add_font_tags($result);
$fonts[] = $result;
}
return $fonts;
}
function fontyourface_get_font($fid, $clear = FALSE) {
static $fonts = array();
if ($clear) {
$fonts = array();
}
if (!isset($fonts[$fid])) {
$fonts[$fid] = db_query('SELECT * FROM {fontyourface_font} WHERE fid = :fid', array(
':fid' => $fid,
))
->fetchObject();
fontyourface_add_font_tags($fonts[$fid]);
}
return $fonts[$fid];
}
function fontyourface_add_font_tags(&$font) {
$font->tags = array();
$query = db_select('fontyourface_tag', 't');
$tag_font_alias = $query
->join('fontyourface_tag_font', 'tf', 'tf.tid = t.tid');
$query
->condition($tag_font_alias . '.fid', $font->fid);
$query
->fields('t');
$result = $query
->execute();
foreach ($result as $tag) {
$font->tags[$tag->tid] = $tag->name;
}
}
function fontyourface_enable_font(&$font) {
db_update('fontyourface_font')
->fields(array(
'enabled' => 1,
))
->condition('fid', $font->fid)
->execute();
$font->enabled = 1;
$enable_function = $font->provider . '_fontyourface_enable';
if (function_exists($enable_function)) {
$enable_function($font);
}
}
function fontyourface_disable_font(&$font) {
db_update('fontyourface_font')
->fields(array(
'enabled' => 0,
))
->condition('fid', $font->fid)
->execute();
$font->enabled = 0;
$disable_function = $font->provider . '_fontyourface_disable';
if (function_exists($disable_function)) {
$disable_function($font);
}
}
function fontyourface_set_css_selector(&$font, $css_selector) {
db_update('fontyourface_font')
->fields(array(
'css_selector' => $css_selector,
))
->condition('fid', $font->fid)
->execute();
$font->css_selector = $css_selector;
}
function fontyourface_save_font(&$font) {
$tags = $font->tags;
unset($font->tags);
$exists = db_query("SELECT fid FROM {fontyourface_font} WHERE url = :url AND provider = :provider", array(
':url' => $font->url,
':provider' => $font->provider,
))
->fetchObject();
if ($exists) {
$existing_font = fontyourface_get_font($exists->fid);
$font->fid = $existing_font->fid;
$font->enabled = $existing_font->enabled;
$font->css_selector = $existing_font->css_selector;
fontyourface_add_font_tags($font);
drupal_write_record('fontyourface_font', $font, 'fid');
}
else {
drupal_write_record('fontyourface_font', $font);
}
db_delete('fontyourface_tag_font')
->condition('fid', $font->fid)
->execute();
if (!is_array($tags)) {
$tags = array();
}
fontyourface_add_tags_to_font($tags, $font->fid);
$font->tags = $tags;
}
function fontyourface_add_tags_to_font($tags, $fid) {
foreach ($tags as $tag) {
$tag_object = new StdClass();
$tag_object->name = $tag;
fontyourface_save_tag($tag_object);
$tag_font = new StdClass();
$tag_font->tid = $tag_object->tid;
$tag_font->fid = $fid;
drupal_write_record('fontyourface_tag_font', $tag_font);
}
}
function fontyourface_save_tag(&$tag) {
$exists = db_query("SELECT tid FROM {fontyourface_tag} WHERE name = :name", array(
':name' => $tag->name,
))
->fetchObject();
if ($exists) {
$tag->tid = $exists->tid;
}
else {
drupal_write_record('fontyourface_tag', $tag);
}
}
function fontyourface_preview($font, $text) {
fontyourface_font_registry($font);
$function = $font->provider . '_fontyourface_preview';
if (function_exists($function)) {
return $function($font, $text);
}
return $text;
}
function fontyourface_font_registry($font = FALSE, $clear = FALSE) {
static $fonts = array();
if ($clear) {
$fonts = array();
}
if ($font) {
$fonts[$font->fid] = $font;
}
return $fonts;
}
function fontyourface_font_css($font) {
$css = array();
if ($font->css_family) {
$css[] = 'font-family: ' . $font->css_family . ';';
}
if ($font->css_style) {
$css[] = 'font-style: ' . $font->css_style . ';';
}
if ($font->css_weight) {
$css[] = 'font-weight: ' . $font->css_weight . ';';
}
return implode(' ', $css);
}
function fontyourface_provider_disable($provider) {
db_delete('fontyourface_font')
->condition('provider', $provider)
->execute();
fontyourface_delete_unused_tags();
}
function fontyourface_delete_unused_tags() {
$missing_font_query = db_select('fontyourface_tag_font', 'tf');
$font_alias = $missing_font_query
->leftJoin('fontyourface_font', 'f', 'tf.fid = f.fid');
$missing_fonts = $missing_font_query
->isNull($font_alias . '.fid')
->fields('tf', array(
'fid',
))
->execute();
$missing_fids = array();
foreach ($missing_fonts as $missing_font) {
$missing_fids[] = $missing_font->fid;
}
if (count($missing_fids) > 0) {
db_delete('fontyourface_tag_font')
->condition('fid', $missing_fids, 'IN')
->execute();
}
$missing_tag_font_query = db_select('fontyourface_tag', 't');
$tag_font_alias = $missing_tag_font_query
->leftJoin('fontyourface_tag_font', 'tf', 'tf.tid = t.tid');
$missing_tags = $missing_tag_font_query
->isNull($tag_font_alias . '.fid')
->fields('t', array(
'tid',
))
->execute();
$missing_tids = array();
foreach ($missing_tags as $missing_tag) {
$missing_tids[] = $missing_tag->tid;
}
if (count($missing_tids) > 0) {
db_delete('fontyourface_tag')
->condition('tid', $missing_tids, 'IN')
->execute();
}
}