/** * Get detailed info for tags used in an entry * * @param string $template * @return string */ function snippet_ttaglist($template = '') { global $PIVOTX; $aTagsList = getTags(false); if (sizeof($aTagsList) > 0) { $output = "<div id='tagpage'>\n"; $output .= "<h3>" . __('Tags used in this posting') . "</h3>\n"; $tagLinks = array(); foreach ($aTagsList as $sTag) { makeRelatedTags($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 = getEntriesWithTag($sRelated, $PIVOTX['db']->entry["code"]); if (!strlen($sTheRelatedLinks) == 0) { $output .= "\n<h3>"; $output .= __('Other entries about') . " '" . $sRelated . "'</h3>\n"; $output .= $sTheRelatedLinks; } } $output .= "\n</div>\n"; } else { $output = ''; } return $output; }
/** * Write out all tags for any given entry.. * * @param array $entry */ function writeTags($tags, $oldtags, $code) { // Tags are separated by space(s) if (is_string($tags)) { if ($tags == '') { return; // Nothing to do } else { $tags = preg_split('/,?[ ]+/', $tags); } } // Loop through new tags, and add them.. if (is_array($tags) && count($tags) > 0) { foreach ($tags as $tag) { writeTag($tag, $code); makeRelatedTags($tag, $tags); } } // Loop through old tags, and delete them if they are no longer present. if (is_string($oldtags)) { if ($oldtags == '') { return; // Nothing to do } else { $oldtags = preg_split('/,?[ ]+/', $oldtags); } } if (is_array($oldtags) && count($oldtags) > 0) { foreach ($oldtags as $oldtag) { if (!in_array($oldtag, $tags)) { deleteTag($oldtag, $code); } } } }