@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 114 lines 2.7 kB view raw
1<?php 2 3final class PhabricatorFulltextToken extends Phobject { 4 5 private $token; 6 private $isShort; 7 private $isStopword; 8 9 public function setToken(PhutilSearchQueryToken $token) { 10 $this->token = $token; 11 return $this; 12 } 13 14 /** 15 * @return PhutilSearchQueryToken 16 */ 17 public function getToken() { 18 return $this->token; 19 } 20 21 public function isQueryable() { 22 return !$this->getIsShort() && !$this->getIsStopword(); 23 } 24 25 public function setIsShort($is_short) { 26 $this->isShort = $is_short; 27 return $this; 28 } 29 30 public function getIsShort() { 31 return $this->isShort; 32 } 33 34 public function setIsStopword($is_stopword) { 35 $this->isStopword = $is_stopword; 36 return $this; 37 } 38 39 public function getIsStopword() { 40 return $this->isStopword; 41 } 42 43 public function newTag() { 44 $token = $this->getToken(); 45 46 $tip = null; 47 $icon = null; 48 49 $name = $token->getValue(); 50 $function = $token->getFunction(); 51 if ($function !== null) { 52 $name = pht('%s: %s', $function, $name); 53 } 54 55 if ($this->getIsShort()) { 56 $shade = PHUITagView::COLOR_GREY; 57 $tip = pht('Ignored Short Word'); 58 } else if ($this->getIsStopword()) { 59 $shade = PHUITagView::COLOR_GREY; 60 $tip = pht('Ignored Common Word'); 61 } else { 62 $operator = $token->getOperator(); 63 switch ($operator) { 64 case PhutilSearchQueryCompiler::OPERATOR_NOT: 65 $tip = pht('Excluding Search'); 66 $shade = PHUITagView::COLOR_RED; 67 $icon = 'fa-minus'; 68 break; 69 case PhutilSearchQueryCompiler::OPERATOR_SUBSTRING: 70 $tip = pht('Substring Search'); 71 $shade = PHUITagView::COLOR_VIOLET; 72 break; 73 case PhutilSearchQueryCompiler::OPERATOR_EXACT: 74 $tip = pht('Exact Search'); 75 $shade = PHUITagView::COLOR_GREEN; 76 break; 77 case PhutilSearchQueryCompiler::OPERATOR_PRESENT: 78 $name = pht('Field Present: %s', $function); 79 $shade = PHUITagView::COLOR_GREEN; 80 break; 81 case PhutilSearchQueryCompiler::OPERATOR_ABSENT: 82 $name = pht('Field Absent: %s', $function); 83 $shade = PHUITagView::COLOR_RED; 84 break; 85 default: 86 $shade = PHUITagView::COLOR_BLUE; 87 break; 88 } 89 } 90 91 $tag = id(new PHUITagView()) 92 ->setType(PHUITagView::TYPE_SHADE) 93 ->setColor($shade) 94 ->setName($name); 95 96 if ($tip !== null) { 97 Javelin::initBehavior('phabricator-tooltips'); 98 99 $tag 100 ->addSigil('has-tooltip') 101 ->setMetadata( 102 array( 103 'tip' => $tip, 104 )); 105 } 106 107 if ($icon !== null) { 108 $tag->setIcon($icon); 109 } 110 111 return $tag; 112 } 113 114}