diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8743fc205b..033e7c15d2 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2848,6 +2848,7 @@ phutil_register_library_map(array( 'PhabricatorIDsSearchEngineExtension' => 'applications/search/engineextension/PhabricatorIDsSearchEngineExtension.php', 'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php', 'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php', + 'PhabricatorIconDatasource' => 'applications/files/typeahead/PhabricatorIconDatasource.php', 'PhabricatorIconRemarkupRule' => 'applications/macro/markup/PhabricatorIconRemarkupRule.php', 'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php', 'PhabricatorIconSetEditField' => 'applications/transactions/editfield/PhabricatorIconSetEditField.php', @@ -7907,6 +7908,7 @@ phutil_register_library_map(array( 'PhabricatorIDsSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'PhabricatorIDsSearchField' => 'PhabricatorSearchField', 'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter', + 'PhabricatorIconDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorIconRemarkupRule' => 'PhutilRemarkupRule', 'PhabricatorIconSet' => 'Phobject', 'PhabricatorIconSetEditField' => 'PhabricatorEditField', diff --git a/src/applications/files/typeahead/PhabricatorIconDatasource.php b/src/applications/files/typeahead/PhabricatorIconDatasource.php new file mode 100644 index 0000000000..63b554a9b7 --- /dev/null +++ b/src/applications/files/typeahead/PhabricatorIconDatasource.php @@ -0,0 +1,46 @@ +buildResults(); + return $this->filterResultsAgainstTokens($results); + } + + protected function renderSpecialTokens(array $values) { + return $this->renderTokensFromResults($this->buildResults(), $values); + } + + private function buildResults() { + $raw_query = $this->getRawQuery(); + + $icons = id(new PHUIIconView())->getIcons(); + + $results = array(); + foreach ($icons as $icon) { + $display_name = str_replace('fa-', '', $icon); + $result = id(new PhabricatorTypeaheadResult()) + ->setPHID($icon) + ->setName($icon) + ->setIcon($icon) + ->setDisplayname($display_name) + ->addAttribute($icon); + + $results[$icon] = $result; + } + return $results; + } + +}