/** * Answer tag cloud of related tags * * @param Component $mainScreen * @return void * @access public * @since 4/8/08 */ public function getRelatedTagsResult(Component $mainScreen) { ob_start(); print "<h3 style='margin-top: 0px; margin-bottom: 0px;'>" . _("Related Tags:") . "</h3>"; $tag = $this->getTag(); print TagAction::getTagCloudDiv($tag->getRelatedTags(TAG_SORT_FREQ), 'view', 100); $mainScreen->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); }
/** * Build the content for this action * * @return void * @access public * @since 11/07/06 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); // ob_start(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $actionRows->add(new Block(TagAction::getTagMenu(), STANDARD_BLOCK), "100%", null, LEFT, TOP); // Related Tags ob_start(); print "<h3 style='margin-top: 0px; margin-bottom: 0px;'>" . _("Related Tags:") . "</h3>"; $tag = $this->getTag(); print TagAction::getTagCloudDiv($tag->getRelatedTags(TAG_SORT_FREQ), 'view', 100); $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $items = $this->getItems(); $resultPrinter = new IteratorResultPrinter($items, 1, 5, 'getTaggedItemComponent', $this->getViewAction()); $resultLayout = $resultPrinter->getLayout("canViewItem"); // $resultLayout =$resultPrinter->getLayout(); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); // $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); }
/** * Answer the tag cloud for the assets in a repository * * @param object Repository $repository * @return string * @access public * @since 11/14/06 * @static */ static function getTagCloudForRepository($repository, $system, $viewAction = 'viewRepository', $styles = null) { if (!is_object($repository)) { return ""; } $repositoryId = $repository->getId(); $tagManager = Services::getService('Tagging'); $items = array(); $assets = $repository->getAssets(); while ($assets->hasNext()) { $asset = $assets->next(); $items[] = TaggedItem::forId($asset->getId(), $system); } return TagAction::getTagCloudDiv($tagManager->getTagsForItems(new HarmoniIterator($items), TAG_SORT_ALFA, 100), $viewAction, $styles, array('repository_id' => $repositoryId->getIdString(), 'system' => $system)); }
/** * Add display of tags * * @param Component $mainScreen * @return void * @access public * @since 4/7/08 */ public function getResult() { return new Block(TagAction::getTagCloudDiv($this->getTags(), $this->getViewAction()), STANDARD_BLOCK); }
/** * Return the markup that represents the plugin. * Plugin writers should override this method with their own functionality * as needed. * * @return string * @access public * @since 1/12/06 */ public function getMarkup() { ob_start(); if ($this->getFieldValue('edit') && $this->canModify()) { $director = SiteDispatcher::getSiteDirector(); $node = $director->getSiteComponentById($this->getId()); $currentTarget = $this->getTargetNodeId(); $node = $director->getSiteComponentById($this->getId()); print "\n" . $this->formStartTagWithAction(); $visitor = new UmbrellaVisitor(); $node->acceptVisitor($visitor); print "<div>"; print _('Chose a section or page:'); print "<select name='" . $this->getFieldName('tagNode') . "'>"; $this->writeUmbrellaSelect($visitor->getNodeData(), $currentTarget); print "</select>\n"; print "<div class='tags_display_options'>" . _('Only tags from your selected section or page will be displayed') . "</div><br/>\n"; print "<select name='" . $this->getFieldName('defaultSortMethod') . "'>"; print "\n\t<option value='alpha' "; if ($this->readOption('defaultSortMethod') == 'alpha') { print "selected='selected'"; } print ">" . _('sort tags alphabetically') . "</option>"; print "\n\t<option value='freq' "; if ($this->readOption('defaultSortMethod') == 'freq') { print "selected='selected'"; } print ">" . _('sort tags by frequency') . "</option>"; print "</select>\n"; print "<br/>"; print "<select name='" . $this->getFieldName('defaultDisplayType') . "'>"; print "\n\t<option value='cloud' "; if ($this->readOption('defaultDisplayType') == 'cloud') { print "selected='selected'"; } print ">" . _('display as cloud') . "</option>"; print "\n\t<option value='list' "; if ($this->readOption('defaultDisplayType') == 'list') { print "selected='selected'"; } print ">" . _('display as list') . "</option>"; print "</select>\n"; print "<br/>"; print "<select name='" . $this->getFieldName('defaultListLimit') . "'>"; print "\n\t<option value='0' "; if ($this->readOption('defaultListLimit') == '0') { print "selected='selected'"; } print ">" . _('in list show: all') . "</option>"; for ($i = 5; $i < 25; $i = $i + 5) { print "\n\t<option value='{$i}' "; if (intval($this->readOption('defaultListLimit')) == $i) { print "selected='selected'"; } print ">" . str_replace('%1', $i, _('in list show: %1')) . "</option>"; } for ($i = 25; $i <= 300; $i = $i + 25) { print "\n\t<option value='{$i}' "; if (intval($this->readOption('defaultListLimit')) == $i) { print "selected='selected'"; } print ">" . str_replace('%1', $i, _('in list show: %1')) . "</option>"; } print "</select>\n"; print "<br/>"; print "<br/>"; print "<input type='submit' value='Update' name='" . $this->getFieldName('submit') . "'>\n"; print "\n\t<input type='button' value='" . _('Cancel') . "' onclick=" . $this->locationSendString() . "/>"; print "</div>"; print "</form>"; } else { if ($this->canView()) { $items = array(); $director = SiteDispatcher::getSiteDirector(); $node = $director->getSiteComponentById($this->getTargetNodeId()); $visitor = new TaggableItemVisitor(); $items = $node->acceptVisitor($visitor); print "\n<div class='breadcrumbs' style='height: auto; margin-top: 1px; margin-bottom: 5px; border-bottom: 1px dotted; padding-bottom: 2px;'>"; print str_replace('%1', $node->acceptVisitor(new BreadCrumbsVisitor($node)), _("Tags within: %1")); print "</div>"; print "\n<div style='text-align: justify;' id='tag_cloud_container-" . $this->getId() . "'>"; $tags = TagAction::getTagsFromItems($items); //SiteDispatcher::passthroughContext(); print TagAction::getTagCloudDiv($tags, 'sitetag', TagAction::getDefaultStyles(), array(), array(null => array('node' => $this->getTargetNodeId()))); //SiteDispatcher::forgetContext(); ?> <script type="text/javascript"> // <![CDATA[ var cloudParent = document.get_element_by_id('tag_cloud_container-<?php print $this->getId(); ?> '); var clouds = document.get_elements_by_class('tag_cloud', cloudParent); var cloud = TagCloud.forContainer(clouds[0]); <?php if ($this->readOption('defaultListLimit') != 15) { print "\n\tcloud.tagList.setLimit(" . $this->readOption('defaultListLimit') . ");"; } if ($this->readOption('defaultSortMethod') == 'freq') { print "\n\tcloud.orderFreq();"; } if ($this->readOption('defaultDisplayType') == 'list') { print "\n\tcloud.showList();"; } ?> // ]]> </script> <?php print "</div>"; if ($this->shouldShowControls()) { print "\n<div style='text-align: right; white-space: nowrap;'>"; print "\n\t<a " . $this->href(array('edit' => 'true')) . ">" . _('edit') . "</a>"; print "\n</div>"; } /* $visitor = new UmbrellaVisitor; $node->acceptVisitor($visitor); print "<br/><pre>"; print_r($visitor->getNodeData()); print "</pre><br/>\n"; */ } } return ob_get_clean(); }