/** * Write out all tags for any given entry.. * * @param array $entry */ function writeTags($tags, $oldtags, $code) { if (is_string($tags)) { $tags = explode(", ", $tags); } $oldtags = explode(", ", $oldtags); // Loop through new tags, and add them.. if (is_array($tags) && count($tags) > 0) { foreach ($tags as $tag) { writeTag($tag, $code); make_related_tags($tag, $tags); } } // Loop through old tags, and delete them if they are no longer present. if (is_array($oldtags) && count($oldtags) > 0) { foreach ($oldtags as $oldtag) { if (!in_array($oldtag, $tags)) { deleteTag($oldtag, $code); } } } }
/** * Get detailed info for tags used in an entry * * @param string $template * @return string */ function snippet_ttaglist($template = "") { global $db, $Paths; $aTagsList = getTags(false); if (sizeof($aTagsList) > 0) { $output = "<div id='tagpage'>\n"; $output .= "<h3>" . lang('tags', 'tags_in_posting') . "</h3>\n"; $tagLinks = array(); foreach ($aTagsList as $sTag) { make_related_tags($sTag, $aTagsList); $tagLinks[] = sprintf('<a rel="tag" href="%s" title="tag: %s">%s</a>', tagLink($sTag, $template), $sTag, $sTag); } $output .= "<p>" . implode(", ", $tagLinks) . "</p>\n"; reset($aTagsList); foreach ($aTagsList as $sRelated) { $sTheRelatedLinks = get_entries_with_tag($sRelated, $db->entry["code"]); if (!strlen($sTheRelatedLinks) == 0) { $output .= "\n<h3>"; $output .= lang('tags', 'other_posts_with_tag') . " '" . $sRelated . "'</h3>\n"; $output .= $sTheRelatedLinks; } } $output .= "\n</div>\n"; } else { $output = ""; } return $output; }