function printTagCloud($tags) { global $setting, $tags_id, $tags_url, $lang_tags_id, $thisismochi; // $tags is the array asort($tags); $tags = array_splice($tags, -60); ksort($tags); $max_size = 24; // max font size in pixels $min_size = 12; // min font size in pixels // largest and smallest array values $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); // find the range of values $spread = $max_qty - $min_qty; if ($spread == 0) { // we don't want to divide by zero $spread = 1; } if (isset($thisismochi)) { $location_extra = '../'; } else { $location_extra = ''; } // set the font-size increment $step = ($max_size - $min_size) / $spread; $myFile = $location_extra . "../../includes/modules/tag_cloud.php"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, '<div class="tag_cloud">'); // loop through the tag array foreach ($tags as $key => $value) { // calculate font-size // find the $value in excess of $min_qty // multiply by the font-size increment ($size) // and add the $min_size set above if ($value >= 2) { $size = round($min_size + ($value - $min_qty) * $step); $tag_link = TagUrl($tags_url[$key], 1, 'newest'); $new_tag = '<a href="' . $tag_link . '" style="font-size: ' . $size . 'px">' . $key . '</a> '; fwrite($fh, $new_tag); } } fwrite($fh, '</div>'); fclose($fh); }
<?php // Grab data $child_tags = $this->data('ChildTags'); // Build HTML list. $html_li_build = ''; $tpl_ul = '<ul class="tagging-child-tags">%s</ul>'; $tpl_li = '<li class="tagging-%s"><a href="%s" title="%s">%s</a><span class="count-discussions" title="Total discussions">%u</span></li>'; foreach ($child_tags as $child_tag) { $html_li_build .= sprintf($tpl_li, $child_tag['Name'], TagUrl($child_tag), $child_tag['FullName'], $child_tag['FullName'], $child_tag['CountDiscussions']); } // Output HTML printf($tpl_ul, $html_li_build);
/** * Create breadcrumbs for tag listings. * * @param object $data Sender->Data object */ protected function setTagBreadcrumbs($data) { if (isset($data['Tag']) && isset($data['Tags'])) { $ParentTag = array(); $CurrentTag = $data['Tag']; $CurrentTags = $data['Tags']; $ParentTagID = $CurrentTag['ParentTagID'] ? $CurrentTag['ParentTagID'] : ''; foreach ($CurrentTags as $Tag) { foreach ($Tag as $SubTag) { if ($SubTag['TagID'] == $ParentTagID) { $ParentTag = $SubTag; } } } $Breadcrumbs = array(); if (is_array($ParentTag) && count(array_filter($ParentTag))) { $Breadcrumbs[] = array('Name' => $ParentTag['FullName'], 'Url' => TagUrl($ParentTag)); } if (is_array($CurrentTag) && count(array_filter($CurrentTag))) { $Breadcrumbs[] = array('Name' => $CurrentTag['FullName'], 'Url' => TagUrl($CurrentTag)); } if (count($Breadcrumbs)) { // Rebuild breadcrumbs in discussions when there is a child, as the // parent must come before it. Gdn::Controller()->SetData('Breadcrumbs', $Breadcrumbs); } } }
public function ToString() { if (!$this->_TagData) { $this->GetData(); } if ($this->_TagData->NumRows() == 0) { return ''; } $String = ''; ob_start(); ?> <div class="Box Tags"> <h4><?php echo T($this->ParentID > 0 ? 'Tagged' : 'Popular Tags'); ?> </h4> <ul class="TagCloud"> <?php foreach ($this->_TagData->Result() as $Tag) { if ($Tag['Name'] != '') { ?> <li><span><?php echo Anchor(TagFullName($Tag), TagUrl($Tag), array('class' => 'Tag_' . str_replace(' ', '_', $Tag['Name']))); ?> </span> <span class="Count"><?php echo number_format($Tag['CountDiscussions']); ?> </span></li> <?php } } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
/** * * * @return string */ public function toString() { if (!$this->_TagData) { $this->getData(); } if ($this->_TagData->numRows() == 0) { return ''; } $String = ''; ob_start(); ?> <div class="Box Tags"> <?php echo panelHeading(t($this->ParentID > 0 ? 'Tagged' : 'Popular Tags')); ?> <ul class="TagCloud"> <?php foreach ($this->_TagData->result() as $Tag) { ?> <?php if ($Tag['Name'] != '') { ?> <li><?php echo anchor(TagFullName($Tag) . ' ' . Wrap(number_format($Tag['CountDiscussions']), 'span', array('class' => 'Count')), TagUrl($Tag, '', '/'), array('class' => 'Tag_' . str_replace(' ', '_', $Tag['Name']))); ?> </li> <?php } ?> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
$low = $page - 4; $high = $page + 8; for ($i = 1; $i <= $total_pages; $i++) { if ($i > $low && $i < $high) { if ($page == $i) { echo '<a class="onstate" href="#">' . $i . '</a> '; } else { $url = TagUrl($get_tag, $i, $sortby); echo '<a href="' . $url . '">' . $i . '</a> '; } } } if ($page < $total_pages - 8) { $penultimate = $total_pages - 1; $url = TagUrl($get_tag, $penultimate, $sortby); echo ' ... <a href="' . $url . '">' . $penultimate . '</a> '; } if ($page < $total_pages - 7) { $url = TagUrl($get_tag, $total_pages, $sortby); echo '<a href="' . $url . '">' . $total_pages . '</a> '; } if ($page < $total_pages) { $next = $page + 1; $url = TagUrl($get_tag, $next, $sortby); echo '<a href="' . $url . '">' . NEXT . ' »</a> '; } echo '</div>'; } else { // Tag not found echo PAGE_NOT_FOUND_INFO; }
/** * * * @param $Filename * @param $Get * @return bool|string */ public function filenameRedirect($Filename, $Get) { trace(['Filename' => $Filename, 'Get' => $Get], 'Testing'); $Filename = strtolower($Filename); array_change_key_case($Get); if (!isset(self::$Files[$Filename])) { return false; } $Row = self::$Files[$Filename]; if (is_callable($Row)) { // Use a callback to determine the translation. $Row = call_user_func_array($Row, [&$Get]); } trace($Get, 'New Get'); // Translate all of the get parameters into new parameters. $Vars = array(); foreach ($Get as $Key => $Value) { if (!isset($Row[$Key])) { continue; } $Opts = (array) $Row[$Key]; if (isset($Opts['Filter'])) { // Call the filter function to change the value. $R = call_user_func($Opts['Filter'], $Value, $Opts[0]); if (is_array($R)) { if (isset($R[0])) { // The filter can change the column name too. $Opts[0] = $R[0]; $Value = $R[1]; } else { // The filter can return return other variables too. $Vars = array_merge($Vars, $R); $Value = null; } } else { $Value = $R; } } if ($Value !== null) { $Vars[$Opts[0]] = $Value; } } trace($Vars, 'Translated Arguments'); // Now let's see what kind of record we have. // We'll check the various primary keys in order of importance. $Result = false; if (isset($Vars['CommentID'])) { trace("Looking up comment {$Vars['CommentID']}."); $CommentModel = new CommentModel(); // If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) { $Comment = $CommentModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']])->FirstRow(); } else { $Comment = $CommentModel->GetID($Vars['CommentID']); } if ($Comment) { $Result = CommentUrl($Comment, '//'); } } elseif (isset($Vars['DiscussionID'])) { trace("Looking up discussion {$Vars['DiscussionID']}."); $DiscussionModel = new DiscussionModel(); $DiscussionID = $Vars['DiscussionID']; $Discussion = false; if (is_numeric($DiscussionID)) { // If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) { $Discussion = $DiscussionModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $DiscussionID])->FirstRow(); } else { $Discussion = $DiscussionModel->GetID($Vars['DiscussionID']); } } else { // This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table. $DiscussionModel->DefineSchema(); if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) { $Discussion = $DiscussionModel->GetWhere(['UrlCode' => $DiscussionID])->FirstRow(); } } if ($Discussion) { $Result = DiscussionUrl($Discussion, self::pageNumber($Vars, 'Vanilla.Comments.PerPage'), '//'); } } elseif (isset($Vars['UserID'])) { trace("Looking up user {$Vars['UserID']}."); $User = Gdn::UserModel()->GetID($Vars['UserID']); if ($User) { $Result = Url(UserUrl($User), '//'); } } elseif (isset($Vars['TagID'])) { $Tag = TagModel::instance()->GetID($Vars['TagID']); if ($Tag) { $Result = TagUrl($Tag, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//'); } } elseif (isset($Vars['CategoryID'])) { trace("Looking up category {$Vars['CategoryID']}."); // If a legacy slug is provided (assigned during a merge), attempt to lookup the category ID based on it if (isset($Get['legacy']) && Gdn::Structure()->Table('Category')->ColumnExists('ForeignID')) { $CategoryModel = new CategoryModel(); $Category = $CategoryModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CategoryID']])->FirstRow(); } else { $Category = CategoryModel::Categories($Vars['CategoryID']); } if ($Category) { $Result = categoryUrl($Category, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//'); } } elseif (isset($Vars['CategoryCode'])) { trace("Looking up category {$Vars['CategoryCode']}."); $category = CategoryModel::instance()->getByCode($Vars['CategoryCode']); if ($category) { $pageNumber = self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'); if ($pageNumber > 1) { $pageParam = '?Page=' . $pageNumber; } else { $pageParam = null; } $Result = categoryUrl($category, '', '//') . $pageParam; } } return $Result; }
/** * Create breadcrumbs for tag listings. * * @param Gdn_Controller $sender Controller object */ protected function setTagBreadcrumbs($sender) { if (null !== $sender->data('Tag', null) && null !== $sender->data('Tags')) { $ParentTag = array(); $CurrentTag = $sender->data('Tag'); $CurrentTags = $sender->data('Tags'); $ParentTagID = $CurrentTag['ParentTagID'] ? $CurrentTag['ParentTagID'] : ''; foreach ($CurrentTags as $Tag) { foreach ($Tag as $SubTag) { if ($SubTag['TagID'] == $ParentTagID) { $ParentTag = $SubTag; } } } $Breadcrumbs = array(); if (is_array($ParentTag) && count(array_filter($ParentTag))) { $Breadcrumbs[] = array('Name' => $ParentTag['FullName'], 'Url' => TagUrl($ParentTag, '', '/')); } if (is_array($CurrentTag) && count(array_filter($CurrentTag))) { $Breadcrumbs[] = array('Name' => $CurrentTag['FullName'], 'Url' => TagUrl($CurrentTag, '', '/')); } if (count($Breadcrumbs)) { // Rebuild breadcrumbs in discussions when there is a child, as the // parent must come before it. $sender->setData('Breadcrumbs', $Breadcrumbs); } } }
function TagList($id, $spacer, $link) { global $setting, $game_keywords, $lang_tags_id; $tags = mysql_query("\n\tSELECT *\n\tFROM ava_tag_relations bt, ava_tags t\n\tWHERE bt.tag_id = t.id\n\tAND bt.game_id = {$id}\n\tGROUP BY bt.id\n\t") or die(mysql_error()); $tag_list = ''; $tag_no = 0; while ($get_tags = mysql_fetch_array($tags)) { $tag_link = TagUrl($get_tags['seo_url'], 1, 'newest'); if ($tag_no == 1) { if ($link == 1) { $tag_list = $tag_list . $spacer . '<a href="' . $tag_link . '">' . $get_tags['tag_name'] . '</a>'; $game_keywords = $game_keywords . ',' . $get_tags['tag_name']; } else { $tag_list = $tag_list . $spacer . $get_tags['tag_name']; } } else { if ($link == 1) { $tag_list = $tag_list . '<a href="' . $tag_link . '">' . $get_tags['tag_name'] . '</a>'; $game_keywords = $game_keywords . $get_tags['tag_name']; } else { $tag_list = $tag_list . $get_tags['tag_name']; } $tag_no = 1; } } return $tag_list; }