/** * Print out the tag page for any given tag. Returns the output as HTML. * * @param string $tag * @return string */ function printTag($tag) { global $Paths, $Cfg, $Current_weblog; $tag = normalizeTag($tag); if (!file_exists($Paths['pivot_path'] . "db/tagdata/" . $tag . ".tag")) { return "No such tag"; } // If magic_quotes_gpc is set, we need to strip slashes.. if (get_magic_quotes_gpc()) { $tag = stripslashes($tag); } if (file_exists($Paths['pivot_path'] . "db/tagdata/" . $tag . "-tagpage.cache")) { if (filectime($Paths['pivot_path'] . "db/tagdata/" . $tag . "-tagpage.cache") < time() - 60 * $Cfg['tag_cache_timeout']) { @unlink($Paths['pivot_path'] . "db/tagdata/" . $tag . "-tagpage.cache"); } else { return "<!--CACHE HIT-->" . file_get_contents($Paths['pivot_path'] . "db/tagdata/" . $tag . "-tagpage.cache"); } } if ($Cfg['tag_fetcher_enabled']) { $para_weblog = "?w=" . para_weblog($Current_weblog); $output = ' <script type="text/javascript" src="' . $Paths['pivot_url'] . 'includes/js/jquery.js"></script> <script type="text/javascript"> /*<![CDATA[ */ function doList(type, tag) { $("#tgrrsslist").html(\'<img src="' . $Paths['pivot_url'] . 'pics/taggerati/loading_\' + type + \'.gif" alt=""/>\'); var url = "' . $Paths['pivot_url'] . 'includes/ajax_rsslist.php' . $para_weblog . '"; $.get( url, { type: type, tag: tag }, function(output) { $("#tgrrsslist").html(output); } ); } /* ]]> */ </script> '; } $output .= "<div id='tagpage'>\n<h2>" . lang('tags', 'tagoverview_header') . " '" . str_replace("+", " ", $tag) . "'</h2>\n\n"; $output .= "<h3>" . lang('tags', 'entries_with_tag') . " '" . str_replace("+", " ", $tag) . "'</h3>\n\n"; $output .= get_entries_with_tag($tag); $output .= "<h3>" . lang('tags', 'related_tags') . "</h3>\n\n"; if (file_exists($Paths['pivot_path'] . "db/tagdata/" . $tag . ".rel")) { $fpTagFile = fopen($Paths['pivot_path'] . "db/tagdata/" . $tag . ".rel", "r"); $sTagString = ""; while (!feof($fpTagFile)) { $sTagString .= fread($fpTagFile, 4096); } fclose($fpTagFile); $aTagList = explode(",", $sTagString); $nCount = 0; foreach ($aTagList as $sThisTag) { $output .= "\n<a href=\"" . tagLink(str_replace(" ", "+", $sThisTag)) . "\" class=\"taglinkext\">{$sThisTag}</a>"; $nCount++; if ($nCount < sizeof($aTagList)) { $output .= ", "; } } } else { $output .= "\n<p>" . lang('tags', 'no_related_tags') . "<p>\n"; } if ($Cfg['tag_fetcher_enabled']) { $output .= "\n<div id='feedfetcher'>\n"; $output .= "<h3>" . lang('tags', 'external_feeds') . " '" . str_replace("+", " ", $tag) . "'</h3>\n\n"; $output .= "<p>\n" . lang('tags', 'click_icon') . " '" . str_replace("+", " ", $tag) . "'</p>\n<p id='tagbuttons'>\n"; $sites = array('technorati' => 'Technorati', 'delicious' => 'Del.icio.us', 'furl' => 'Furl', 'magnolia' => 'Ma.gnolia', 'google' => 'Google', 'feedster' => 'Feedster', 'icerocket' => 'Icerocket', 'tagzania' => 'TagZania', 'shadows' => 'Shadows', 'feedmarker' => 'Feedmarker', '43things' => '43 Things'); foreach ($sites as $key => $value) { $output .= sprintf("<a href=\"javascript:doList('%s','%s');\"><img src=\"%spics/taggerati/%s.png\" alt=\"%s\" /></a>\n", $key, str_replace('/', '', $_GET['tag']), $Paths['pivot_url'], $key, $value); } $output .= "</p>"; $output .= "<div id=\"tgrrsslist\"></div>"; $output .= "</div>\n"; } if ($Cfg['tag_flickr_enabled']) { $output .= "<h3>" . lang('tags', 'flickr_images') . " '" . str_replace("+", " ", $tag) . "'</h3>\n\n"; $output .= ' <!-- Start of Flickr Badge --> <div id="flickrpics"> <table><tr> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=' . $Cfg['tag_flickr_amount'] . '&display=latest&size=s&layout=h&source=all_tag&tag=' . $tag . '"></script> </tr></table> </div> '; } $output .= "</div>\n"; $output .= "<!-- cached at: " . date("H:i", time()) . "-->"; // Since it'll be built in, we don't want to display Marco's name on every page. Sorry Marco, you know we love you! ;-) // $output .= "<br/><br/><small>Taggerati extension for <a href=\"http://www.pivotlog.net/\">Pivot</a> by <a href=\"http://www.i-marco.nl/weblog/\">Marco van Hylckama Vlieg</a></small>"; write_file($Paths['pivot_path'] . "db/tagdata/" . $tag . "-tagpage.cache", $output); return $output; }
/** * 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; }