You are here

function nodewords_save_tags in Nodewords: D6 Meta Tags 6.2

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

Update or insert tags in the table.

5 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_custom_pages_edit_submit in nodewords_custom_pages/nodewords_custom_pages.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 593
Implement an API that other modules can use to add meta tags.

Code

function nodewords_save_tags($tags, $options = array()) {
  $done = FALSE;
  $options += _nodewords_get_default_metatags_type() + array(
    'log_message' => variable_get('nodewords_save_tags_watchdog', 0),
  );
  $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', 'Meta tags changed for type @type @id.', array(
          '@type' => isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'),
          '@id' => $options['id'],
        ));
        $done = TRUE;
      }
    }
  }
}