function nodewords_save_tags in Nodewords: D6 Meta Tags 6
Same name and namespace in other branches
- 6.3 nodewords.module \nodewords_save_tags()
- 6.2 nodewords.module \nodewords_save_tags()
Update or insert tags in the table.
5 calls to nodewords_save_tags()
- nodewords_custom_pages_edit_submit in ./
nodewords.admin.inc - Submission function for the meta tags edit page.
- nodewords_nodeapi in ./
nodewords.module - Implements hook_nodeapi().
- nodewords_tags_form_submit in ./
nodewords.admin.inc - Submission function for the meta tags edit page.
- nodewords_taxonomy in ./
nodewords.module - Implements hook_taxonomy().
- nodewords_user in ./
nodewords.module - Implements hook_user().
File
- ./
nodewords.module, line 1118 - Implement an API that other modules can use to implement meta tags.
Code
function nodewords_save_tags($type, $id, $tags, $log_message = FALSE) {
global $user;
$done = FALSE;
$tags_info = nodewords_get_possible_tags();
$types_str = array(
NODEWORDS_TYPE_BLOG => t('blog main page'),
NODEWORDS_TYPE_DEFAULT => t('default'),
NODEWORDS_TYPE_ERRORPAGE => t('HTTP error page'),
NODEWORDS_TYPE_FORUM => t('forum main page'),
NODEWORDS_TYPE_FRONTPAGE => t('front page'),
NODEWORDS_TYPE_NODE => t('node'),
NODEWORDS_TYPE_OFFLINE => t('site offline page'),
NODEWORDS_TYPE_PAGE => t('custom page'),
NODEWORDS_TYPE_PAGER => t('list page'),
NODEWORDS_TYPE_TERM => t('taxonomy term'),
NODEWORDS_TYPE_USER => t('user profile'),
NODEWORDS_TYPE_VOCABULARY => t('vocabulary'),
);
foreach ($tags as $name => $content) {
if (isset($tags_info[$name])) {
$content = serialize($content);
$result = db_fetch_object(db_query_range("SELECT * FROM {nodewords} WHERE type = %d AND id = %d AND name = '%s'", $type, $id, $name, 0, 1));
if ($result === FALSE) {
$row = new stdClass();
$row->type = $type;
$row->id = $id;
$row->name = $name;
}
else {
$row = $result;
}
$row->content = $content;
drupal_write_record('nodewords', $row, $result !== FALSE ? 'mtid' : array());
if (!$done) {
watchdog('nodewords', 'User %name changed the meta tags for type %type (ID %id).', array(
'%name' => $user->name,
'%type' => isset($types_str[$type]) ? $types_str[$type] : t('unknown'),
'%id' => $id,
));
$done = TRUE;
}
}
}
// Reload the tags so that future API calls get the correct data.
nodewords_load_tags($type, $id);
}