You are here

function fontyourface_admin_edit_form_submit in @font-your-face 7

Same name and namespace in other branches
  1. 6.2 fontyourface.module \fontyourface_admin_edit_form_submit()
  2. 6 fontyourface.module \fontyourface_admin_edit_form_submit()

Edit form submit handler.

File

./fontyourface.module, line 722

Code

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);
    }

    // elseif
    if ($font->css_selector != $form['css']['#value']) {
      fontyourface_set_css_selector($font, $form['css']['#value']);
    }

    // if
    $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();
    }

    // if
    drupal_set_message(t('Updated') . ' <i>' . $font->name . '</i>.');
  }

  // else
}