You are here

function nodewords_save_tags in Nodewords: D6 Meta Tags 6.3

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

Update or insert tags in the table.

4 calls to nodewords_save_tags()
nodewords_admin_tags_edit_form_submit in nodewords_admin/nodewords_admin.admin.inc
Submission function for the meta tags edit page.
nodewords_nodeapi in ./nodewords.module
Implements hook_nodeapi().
nodewords_taxonomy in ./nodewords.module
Implements hook_taxonomy().
nodewords_user in ./nodewords.module
Implements hook_user().

File

./nodewords.module, line 671
Implement an version that other modules can use to add meta tags.

Code

function nodewords_save_tags($tags, $options = array()) {
  global $language, $user;
  $done = FALSE;
  $options += array(
    'language' => $language->language,
    'log_message' => TRUE,
  ) + _nodewords_get_default_metatags_type();
  $tags_info = nodewords_get_possible_tags();
  $types_str = _nodewords_get_type_strings();
  foreach ($tags as $name => $content) {
    if (isset($tags_info[$name])) {
      $content = serialize($content);
      $result = _nodewords_get_tags_data($name, $options);
      if ($result === FALSE) {
        $row = _nodewords_init_tags_data($name, $options);
      }
      else {
        $row = $result;
      }
      $row->content = $content;
      $ret = drupal_write_record('nodewords', $row, isset($row->mtid) ? 'mtid' : array());
      if (!$done && $options['log_message'] && $ret) {
        watchdog('meta tags', 'User %name changed the meta tags for type %type (%id - %sid).', array(
          '%name' => $user->name,
          isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'),
          '%id' => $options['id'],
          '%sid' => $options['sid'],
        ));
        $done = TRUE;
      }
    }
  }
}