List all tags and allow searching

@param Gdn_Controller $Sender
167163
public function Controller_Index($Sender) {
      $Sender->Title('Tagging');
      $Sender->AddSideMenu('settings/tagging');
      $Sender->AddCSSFile('plugins/Tagging/design/tagadmin.css');
      $Sender->AddJSFile('plugins/Tagging/js/admin.js');
      $SQL = Gdn::SQL();
      
      $Sender->Form->Method = 'get';
      $Sender->Form->InputPrefix = '';
      //$Sender->Form->Action = '/settings/tagging';

      list($Offset, $Limit) = OffsetLimit($Sender->Request->Get('Page'), 100);
      $Sender->SetData('_Limit', $Limit);
      
      if ($Search = $Sender->Request->Get('Search')) {
         $SQL->Like('Name', $Search , 'right');
      }
      
      $Data = $SQL
         ->Select('t.*')
         ->From('Tag t')
         ->OrderBy('t.Name', 'asc')
         ->OrderBy('t.CountDiscussions', 'desc')
         ->Limit($Limit, $Offset)
         ->Get()->ResultArray();

      $Sender->SetData('Tags', $Data);

      if ($Search = $Sender->Request->Get('Search')) {
         $SQL->Like('Name', $Search , 'right');
      }
      $Sender->SetData('RecordCount', $SQL->GetCount('Tag'));
         
      $Sender->Render('tagging', '', 'plugins/Tagging');
   }
1250481
public function Controller_Dismiss($Sender) {
      $Arguments = $Sender->RequestArgs;
      if (sizeof($Arguments) != 2) return;
      list($Controller, $EncodedURL) = $Arguments;
      
      $URL = base64_decode(str_replace('-','=',$EncodedURL));
      
      Gdn::SQL()->Delete('Flag',array(
         'ForeignURL'      => $URL
      ));
      
      $this->Controller_Index($Sender);
   }
1247674
public function MeModule_FlyoutMenu_Handler($Sender) {
		// Add "Mark All Viewed" to menu
		if (Gdn::Session()->IsValid()) {
         echo Wrap(Anchor(T('Mark All Viewed'), '/discussions/markallviewed'), 'li', array('class' => 'MarkAllViewed'));
         
			$CategoryID = (int)(empty(Gdn::Controller()->CategoryID) ? 0 : Gdn::Controller()->CategoryID);
			if ($CategoryID > 0)
            echo Wrap(Anchor(T('Mark Category Viewed'), "/discussions/markcategoryviewed/{$CategoryID}"), 'li', array('class' => 'MarkCategoryViewed'));
		}
	}
458389
public function show(string $tag)
    {
        $tags = Tag::latest('count')
            ->where('name', 'like', '%'.$tag.'%')
            ->limit(10)
            ->get()
            ->map(function ($item) {
                return [
                    'id'    => $item['name'],
                    'text'  => $item['name'],
                    'count' => $item['count'],
                ];
            })
            ->toArray();

        return response()->json($tags);
    }
136539
public function Controller_Delete($Sender) {
      $Sender->Permission('Garden.Settings.Manage');
      
      $TagID = GetValue(1, $Sender->RequestArgs);
      $TagModel = new TagModel();
      $Tag = $TagModel->GetID($TagID, DATASET_TYPE_ARRAY);
      if ($Sender->Form->AuthenticatedPostBack()) {
         // Delete tag & tag relations.
         $SQL = Gdn::SQL();
         $SQL->Delete('TagDiscussion', array('TagID' => $TagID));
         $SQL->Delete('Tag', array('TagID' => $TagID));
         
         $Sender->InformMessage(FormatString(T('<b>{Name}</b> deleted.'), $Tag));
         $Sender->JsonTarget("#Tag_{$Tag['TagID']}", NULL, 'Remove');
      }

      $Sender->SetData('Title', T('Delete Tag'));
      $Sender->Render('delete', '', 'plugins/Tagging');
   }
907439
def list_tag(path = Dir.pwd)
      res = {}
      cg  = MiniGit::Capturing.new(path)
      unless (cg.tag :list => true).empty?
        # git show-ref --tags
        a = (cg.show_ref :tags => true).split("\n")
        res = Hash[ a.collect { |item| item.split(' refs/tags/') } ].invert
      end
      res
    end
480572
private function DiscussionsClickable($Sender) {
      // Make sure that discussion clicks (anywhere in a discussion row) take the user to the discussion.
      if (property_exists($Sender, 'Head') && is_object($Sender->Head)) {
         $Sender->Head->AddString('
<script type="text/javascript">
   jQuery(document).ready(function($) {
      $("ul.DataList li.Item").click(function() {
         var href = $(this).find(".Title a").attr("href");
         if (typeof href != "undefined")
            document.location = href;
      });
   });
</script>');
      }
   }
43332
protected function findTagsByIdentifier(string $identifier): array
    {
        $tags = $this->memcache->get($this->identifierPrefix . 'ident_' . $identifier);
        return ($tags === false ? [] : (array)$tags);
    }
488715
public function ModerationController_MergeDiscussions_Create($Sender) {
      $Session = Gdn::Session();
      $Sender->Form = new Gdn_Form();
      $Sender->Title(T('Merge Discussions'));

      $DiscussionModel = new DiscussionModel();
      $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
      if (!is_array($CheckedDiscussions))
         $CheckedDiscussions = array();
       
      $DiscussionIDs = $CheckedDiscussions;
      $Sender->SetData('DiscussionIDs', $DiscussionIDs);
      $CountCheckedDiscussions = count($DiscussionIDs);
      $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
      $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
      $Sender->SetData('Discussions', $Discussions);
      
      // Perform the merge
      if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
            if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
               $MergeDiscussion = $Discussion;
               break;
            }
         }
         if ($MergeDiscussion) {
            $ErrorCount = 0;
            
            // Verify that the user has permission to perform the merge.
            $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
            if ($Category && !$Category['PermsDiscussionsEdit'])
               throw PermissionException('Vanilla.Discussions.Edit');
            
            // Assign the comments to the new discussion record
            $DiscussionModel->SQL
               ->Update('Comment')
               ->Set('DiscussionID', $MergeDiscussionID)
               ->WhereIn('DiscussionID', $DiscussionIDs)
               ->Put();
               
            $CommentModel = new CommentModel();
            foreach ($Discussions as $Discussion) {
               if ($Discussion['DiscussionID'] == $MergeDiscussionID)
                  continue;
               
               // Create a comment out of the discussion.
               $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
               $Comment['DiscussionID'] = $MergeDiscussionID;
               
               $CommentModel->Validation->Results(TRUE);
               $CommentID = $CommentModel->Save($Comment);
               if ($CommentID) {
                  // Move any attachments (FileUpload plugin awareness)
                  if (class_exists('MediaModel')) {
                     $MediaModel = new MediaModel();
                     $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                  }
                  
                  // Delete discussion that was merged
                  $DiscussionModel->Delete($Discussion['DiscussionID']);                  
               } else {
                  $Sender->InformMessage($CommentModel->Validation->ResultsText());
                  $ErrorCount++;
               }
            }
            // Update counts on all affected discussions.
            $CommentModel->UpdateCommentCount($MergeDiscussionID);
            $CommentModel->RemovePageCache($MergeDiscussionID);
   
            // Clear selections
            Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
            ModerationController::InformCheckedDiscussions($Sender);
            if ($ErrorCount == 0)
               $Sender->RedirectUrl = Url("/discussion/$MergeDiscussionID/".Gdn_Format::Url($MergeDiscussion['Name']));
         }
      }
      
      $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
   }
409107
public function Index($Page = '') {
		$this->AddJsFile('search.js');
		$this->Title(T('Search'));
      
      SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE);
      Gdn_Theme::Section('SearchResults');
      
      list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20));
      $this->SetData('_Limit', $Limit);
		
		$Search = $this->Form->GetFormValue('Search');
      $Mode = $this->Form->GetFormValue('Mode');
      if ($Mode)
         $this->SearchModel->ForceSearchMode = $Mode;
      try {
         $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
      } catch (Gdn_UserException $Ex) {
         $this->Form->AddError($Ex);
         $ResultSet = array();
      } catch (Exception $Ex) {
         LogException($Ex);
         $this->Form->AddError($Ex);
         $ResultSet = array();
      }
      Gdn::UserModel()->JoinUsers($ResultSet, array('UserID'));
      
      // Fix up the summaries.
      $SearchTerms = explode(' ', Gdn_Format::Text($Search));
      foreach ($ResultSet as &$Row) {
         $Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms);
         $Row['Format'] = 'Html';
      }
      
		$this->SetData('SearchResults', $ResultSet, TRUE);
		$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
		if($ResultSet)
			$NumResults = count($ResultSet);
		else
			$NumResults = 0;
		if ($NumResults == $Offset + $Limit)
			$NumResults++;
		
		// Build a pager
		$PagerFactory = new Gdn_PagerFactory();
		$this->Pager = $PagerFactory->GetPager('MorePager', $this);
		$this->Pager->MoreCode = 'More Results';
		$this->Pager->LessCode = 'Previous Results';
		$this->Pager->ClientID = 'Pager';
		$this->Pager->Configure(
			$Offset,
			$Limit,
			$NumResults,
			'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
		);
		
//		if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
//         $this->SetJson('LessRow', $this->Pager->ToString('less'));
//         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
//         $this->View = 'results';
//      }
		
      $this->CanonicalUrl(Url('search', TRUE));

		$this->Render();
	}
526917
def search_tags(self, tag_name):

        

        response = self._req('/browse/tags/search', {
            "tag_name":tag_name
        })

        tags = list()

        for item in response['results']:
            tags.append(item['tag_name'])

        return tags
209253
public function seachtByTag($fieldList, $fieldTag)
    {
        //====================================================================//
        // Safety Checks
        if (!count($fieldList)) {
            return false;
        }
        if (empty($fieldTag)) {
            return false;
        }
        //====================================================================//
        // Walk Through List and select by Tag
        foreach ($fieldList as $field) {
            if ($field["tag"] == $fieldTag) {
                return $field;
            }
        }

        return false;
    }
1057934
public function Gdn_Form_BeforeBodyBox_Handler($Sender) {
      $Wrap = false;
      if (Gdn::Controller() instanceof PostController)
         $Wrap = true;
      $this->AttachButtonBar($Sender, $Wrap);
   }
34607
public function listPrefixedTags($prefix)
    {
        $tags = $this->listTags();
        $len  = strlen($prefix);

        if (0 >= $len) {
            return $tags;
        }

        $tags = array_filter(
            $tags,
            function ($t) use ($prefix, $len) {
                return $prefix === substr($t, 0, $len);
            }
        );

        return array_values($tags);
    }
561723
public function Controller_Edit($Sender) {
      $Sender->AddSideMenu('settings/tagging');
      $Sender->Title(T('Edit Tag'));
      $TagID = GetValue(1, $Sender->RequestArgs);

      // Set the model on the form.
      $TagModel = new TagModel;
      $Sender->Form->SetModel($TagModel);
      $Tag = $TagModel->GetID($TagID);
      $Sender->Form->SetData($Tag);

      // Make sure the form knows which item we are editing.
      $Sender->Form->AddHidden('TagID', $TagID);

      if ($Sender->Form->AuthenticatedPostBack()) {
         // Make sure the tag is valid
         $TagData = $Sender->Form->GetFormValue('Name');
         if (!TagModel::ValidateTag($TagData))
            $Sender->Form->AddError('@'.T('ValidateTag', 'Tags cannot contain commas.'));
         
         // Make sure that the tag name is not already in use.
         if ($TagModel->GetWhere(array('TagID <>' => $TagID, 'Name' => $TagData))->NumRows() > 0) {
            $Sender->SetData('MergeTagVisible', TRUE);
            if (!$Sender->Form->GetFormValue('MergeTag')) {
               $Sender->Form->AddError('The specified tag name is already in use.');
            }
         }
         
         if ($Sender->Form->Save())
            $Sender->InformMessage(T('Your changes have been saved.'));
      }

      $Sender->Render('addedit', '', 'plugins/Tagging');
   }
590795
public function Base_Render_Before($Sender) {
      $Session = Gdn::Session();
      if ($Sender->Menu)
         $Sender->Menu->AddLink('Discussions', T('Discussions'), '/discussions', FALSE, array('Standard' => TRUE));
   }
1339798
public function PostController_Render_Before($Sender) {
      if (strcasecmp($Sender->RequestMethod, 'discussion') == 0 && $Sender->Form->AuthenticatedPostBack() === TRUE)
         $this->SaveStep('Plugins.GettingStarted.Discussion');
   }