/** * Tags Search method * * The sql must return the following fields that are * used in a common display routine: href, title, section, created, text, * browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchTagsAreas()))) { return array(); } } // load plugin params info $plugin = JPluginHelper::getPlugin('search', 'cedtags'); $pluginParams = new JParameter($plugin->params); $limit = $pluginParams->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } $rows = $this->searchForText($text, $limit); $count = count($rows); for ($i = 0; $i < $count; $i++) { $link = 'index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($rows[$i]->name); $rows[$i]->href = JRoute::_($link); $rows[$i]->section = JText::_('TAG'); } $return = array(); foreach ($rows as $key => $tag) { if (searchHelper::checkNoHTML($tag, $searchText, array('name', 'title', 'text'))) { $return[] = $tag; } } return $return; }
/** * * @param $cid * @return array */ public function getModelTags($cid) { $terms = $this->getTagsForArticle($cid); $showRelatedArticles = CedTagsHelper::param('RelatedArticlesByTags', 0); $tags = array(); if (isset($terms) && !empty($terms)) { $singleTermsSuppress = CedTagsHelper::param('SuppresseSingleTerms', 1); $termIds = array(); foreach ($terms as $term) { $frequency = $this->getTagFrequency($term); if ($showRelatedArticles || $singleTermsSuppress) { if (@intval($frequency) <= 1) { if ($singleTermsSuppress) { continue; } } else { $termIds[] = $term->id; } } $date = $term->created; $tag = new stdClass(); $tag->title = JText::sprintf('COM_CEDTAG_ITEMS_TITLE', (string) $frequency, (string) $term->name, (string) $date, (string) $term->hits); $tag->id = $term->id; $tag->link = JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($term->name)); $tag->tag = CedTagsHelper::ucwords($term->name); $tags[] = $tag; } } //Limit size of tags displayed array_splice($tags, intval(CedTagsHelper::param('MaxTagsNumber', 10))); return $tags; }
/** * The second function, [componentname]ParseRoute($segments), must transform an array of segments back into an array of URL parameters. Schematically: * @param $segments * @return array */ function cedtagParseRoute($segments) { $vars = array(); $tag = array_shift($segments); $vars['tag'] = CedTagsHelper::urlTagname($tag); $vars['task'] = 'tag'; $vars['view'] = 'tag'; return $vars; }
" border="0"/> <map name="mymap"> <?php foreach ($this->cloud->get_image_map() as $map) { ?> <area shape="rect" coords="<?php echo $map[1]->get_map_coords(); ?> " title="<?php echo $map[0]; ?> " href="<?php echo JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($map[0])); ?> " /> <?php } ?> </map> </div> <div class="copyright"> <a href="http://www.waltercedric.com" style="font: normal normal normal 10px/normal arial; color: rgb(187, 187, 187); border-bottom-style: none; border-bottom-width: inherit; border-bottom-color: inherit; text-decoration: none; " onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" target="_blank"><b>cedTag</b></a> </div> <!-- CedTag Free Tagging system for Joomla by www.waltercedric.com --> </div>
/** * http://rhodopsin.blogspot.com/2008/05/php-tag-cloud.html * http://en.wikipedia.org/wiki/Pareto_distribution * @param $rows * @return array */ public function mappingFrequencyToSizeWithPareto($rows) { $tags = array(); $tagsNameToRow = array(); foreach ($rows as $row) { $tags[$row->name] = $row->frequency; $tagsNameToRow[$row->name] = $row; } $maxSize = $rows[0]->frequency; $minSize = 1; $tags = $this->fromParetoCurve($tags, $minSize, $maxSize); $result = array(); while (list($tagname, $tagsize) = each($tags)) { $term = new stdClass(); $term->size = $tagsize; $term->link = JRoute::_('index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($tagname)); $term->name = CedTagsHelper::ucwords($tagname); $term->frequency = $tagsNameToRow[$tagname]->frequency; $term->hits = $tagsNameToRow[$tagname]->hits; $term->created = $tagsNameToRow[$tagname]->created; $term->title = JText::sprintf('COM_CEDTAG_ITEMS_TITLE', (string) $term->frequency, (string) $term->name, (string) $term->created, (string) $term->hits); $term->class = 'cedtag'; $result[] = $term; } return $result; }