/** * Print the tag cloud and tagging link for an item * * @param object TaggedItem $item * @param optional string $viewAction The action to use when clicking on a tag. * Usually view or viewuser * @param optional array $styles An array of style-strings to use for various * levels of of tag occurrances. * @return string * @access public * @since 11/14/06 * @static */ static function getTagCloudForItem($item, $viewAction = 'view', $styles = null, $additionalParams = null) { ob_start(); print "\n<div>"; print TagAction::getTagCloud($item->getTags(), $viewAction, $styles, $additionalParams); print "\n\t<span> "; print "\n\t\t<a onclick=\""; print "this.viewAction = '" . $viewAction . "'; "; // register the styles with the tagger if (!is_array($styles)) { $styles = TagAction::getDefaultStyles(); } print "this.styles = new Array(); "; foreach ($styles as $style) { $styleStrings = explode(";", $style); print "this.styles.push({"; $started = false; foreach ($styleStrings as $styleString) { if (preg_match('/([a-z0-9\\-]+):\\s?([a-z0-9\\-\\s%]+)/i', $styleString, $matches)) { // Reformat the style name for javascript $styleName = trim($matches[1]); $styleNameParts = explode('-', $styleName); $styleName = $styleNameParts[0]; for ($i = 1; $i < count($styleNameParts); $i++) { $styleName .= ucfirst($styleNameParts[$i]); } $styleValue = trim($matches[2]); if ($started) { print ", "; } print "'" . $styleName . "': '" . $styleValue . "'"; } } print "}); "; } print "Tagger.run('" . $item->getIdString() . "', '" . $item->getSystem() . "', this, this.parentNode.parentNode"; // Add Context parameters to the urls generated when re-writing the tag cloud. $harmoni = Harmoni::instance(); $contextInfo = $harmoni->request->getContextInfo(); if (count($contextInfo)) { print ", {"; $params = array(); foreach ($contextInfo as $info) { $params[] = $info->name . ": {value: '" . $info->value . "', namespace: '" . $info->namespace . "'}"; } print implode(', ', $params); print "}"; } print ");"; print "\" title='" . _("Add Tags to this Item") . "'"; print " style='font-weight: bold;'>"; print _("+Tag") . "</a>"; print "\n\t</span>"; print "\n</div>"; return ob_get_clean(); }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags SiteDispatcher::passthroughContext(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $block->getQualifierId())) { print "\n\t<div class='tagging_tags_display'>"; print TagAction::getTagCloudForItem($item, 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } else { print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags print "\n\t<div class='tagging_tags_display'>"; print "Tags: "; SiteDispatcher::passthroughContext(); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }