[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/phui/ -> PHUIIconView.php (source)

   1  <?php
   2  
   3  final class PHUIIconView extends AphrontTagView {
   4  
   5    const SPRITE_APPS = 'apps';
   6    const SPRITE_TOKENS = 'tokens';
   7    const SPRITE_PAYMENTS = 'payments';
   8    const SPRITE_LOGIN = 'login';
   9    const SPRITE_PROJECTS = 'projects';
  10  
  11    const HEAD_SMALL = 'phuihead-small';
  12    const HEAD_MEDIUM = 'phuihead-medium';
  13  
  14    private $href = null;
  15    private $image;
  16    private $text;
  17    private $headSize = null;
  18  
  19    private $spriteIcon;
  20    private $spriteSheet;
  21    private $iconFont;
  22    private $iconColor;
  23  
  24    public function setHref($href) {
  25      $this->href = $href;
  26      return $this;
  27    }
  28  
  29    public function setImage($image) {
  30      $this->image = $image;
  31      return $this;
  32    }
  33  
  34    public function setText($text) {
  35      $this->text = $text;
  36      return $this;
  37    }
  38  
  39    public function setHeadSize($size) {
  40      $this->headSize = $size;
  41      return $this;
  42    }
  43  
  44    public function setSpriteIcon($sprite) {
  45      $this->spriteIcon = $sprite;
  46      return $this;
  47    }
  48  
  49    public function setSpriteSheet($sheet) {
  50      $this->spriteSheet = $sheet;
  51      return $this;
  52    }
  53  
  54    public function setIconFont($icon, $color = null) {
  55      $this->iconFont = $icon;
  56      $this->iconColor = $color;
  57      return $this;
  58    }
  59  
  60    public function getTagName() {
  61      $tag = 'span';
  62      if ($this->href) {
  63        $tag = 'a';
  64      }
  65      return $tag;
  66    }
  67  
  68    public function getTagAttributes() {
  69      require_celerity_resource('phui-icon-view-css');
  70  
  71      $style = null;
  72      $classes = array();
  73      $classes[] = 'phui-icon-view';
  74  
  75      if ($this->spriteIcon) {
  76        require_celerity_resource('sprite-'.$this->spriteSheet.'-css');
  77        $classes[] = 'sprite-'.$this->spriteSheet;
  78        $classes[] = $this->spriteSheet.'-'.$this->spriteIcon;
  79      } else if ($this->iconFont) {
  80        require_celerity_resource('phui-font-icon-base-css');
  81        require_celerity_resource('font-fontawesome');
  82        $classes[] = 'phui-font-fa';
  83        $classes[] = $this->iconFont;
  84        if ($this->iconColor) {
  85          $classes[] = $this->iconColor;
  86        }
  87      } else {
  88        if ($this->headSize) {
  89          $classes[] = $this->headSize;
  90        }
  91        $style = 'background-image: url('.$this->image.');';
  92      }
  93  
  94      if ($this->text) {
  95        $classes[] = 'phui-icon-has-text';
  96        $this->appendChild($this->text);
  97      }
  98  
  99      return array(
 100        'href' => $this->href,
 101        'style' => $style,
 102        'aural' => false,
 103        'class' => $classes,
 104      );
 105    }
 106  
 107    public static function getSheetManifest($sheet) {
 108      $root = dirname(phutil_get_library_root('phabricator'));
 109      $path = $root.'/resources/sprite/manifest/'.$sheet.'.json';
 110      $data = Filesystem::readFile($path);
 111      return idx(json_decode($data, true), 'sprites');
 112    }
 113  
 114    public static function getFontIcons() {
 115      return array(
 116        'fa-glass',
 117        'fa-music',
 118        'fa-search',
 119        'fa-envelope-o',
 120        'fa-heart',
 121        'fa-star',
 122        'fa-star-o',
 123        'fa-user',
 124        'fa-film',
 125        'fa-th-large',
 126        'fa-th',
 127        'fa-th-list',
 128        'fa-check',
 129        'fa-times',
 130        'fa-search-plus',
 131        'fa-search-minus',
 132        'fa-power-off',
 133        'fa-signal',
 134        'fa-cog',
 135        'fa-trash-o',
 136        'fa-home',
 137        'fa-file-o',
 138        'fa-clock-o',
 139        'fa-road',
 140        'fa-download',
 141        'fa-arrow-circle-o-down',
 142        'fa-arrow-circle-o-up',
 143        'fa-inbox',
 144        'fa-play-circle-o',
 145        'fa-repeat',
 146        'fa-refresh',
 147        'fa-list-alt',
 148        'fa-lock',
 149        'fa-flag',
 150        'fa-headphones',
 151        'fa-volume-off',
 152        'fa-volume-down',
 153        'fa-volume-up',
 154        'fa-qrcode',
 155        'fa-barcode',
 156        'fa-tag',
 157        'fa-tags',
 158        'fa-book',
 159        'fa-bookmark',
 160        'fa-print',
 161        'fa-camera',
 162        'fa-font',
 163        'fa-bold',
 164        'fa-italic',
 165        'fa-text-height',
 166        'fa-text-width',
 167        'fa-align-left',
 168        'fa-align-center',
 169        'fa-align-right',
 170        'fa-align-justify',
 171        'fa-list',
 172        'fa-outdent',
 173        'fa-indent',
 174        'fa-video-camera',
 175        'fa-picture-o',
 176        'fa-pencil',
 177        'fa-map-marker',
 178        'fa-adjust',
 179        'fa-tint',
 180        'fa-pencil-square-o',
 181        'fa-share-square-o',
 182        'fa-check-square-o',
 183        'fa-arrows',
 184        'fa-step-backward',
 185        'fa-fast-backward',
 186        'fa-backward',
 187        'fa-play',
 188        'fa-pause',
 189        'fa-stop',
 190        'fa-forward',
 191        'fa-fast-forward',
 192        'fa-step-forward',
 193        'fa-eject',
 194        'fa-chevron-left',
 195        'fa-chevron-right',
 196        'fa-plus-circle',
 197        'fa-minus-circle',
 198        'fa-times-circle',
 199        'fa-check-circle',
 200        'fa-question-circle',
 201        'fa-info-circle',
 202        'fa-crosshairs',
 203        'fa-times-circle-o',
 204        'fa-check-circle-o',
 205        'fa-ban',
 206        'fa-arrow-left',
 207        'fa-arrow-right',
 208        'fa-arrow-up',
 209        'fa-arrow-down',
 210        'fa-share',
 211        'fa-expand',
 212        'fa-compress',
 213        'fa-plus',
 214        'fa-minus',
 215        'fa-asterisk',
 216        'fa-exclamation-circle',
 217        'fa-gift',
 218        'fa-leaf',
 219        'fa-fire',
 220        'fa-eye',
 221        'fa-eye-slash',
 222        'fa-exclamation-triangle',
 223        'fa-plane',
 224        'fa-calendar',
 225        'fa-random',
 226        'fa-comment',
 227        'fa-magnet',
 228        'fa-chevron-up',
 229        'fa-chevron-down',
 230        'fa-retweet',
 231        'fa-shopping-cart',
 232        'fa-folder',
 233        'fa-folder-open',
 234        'fa-arrows-v',
 235        'fa-arrows-h',
 236        'fa-bar-chart-o',
 237        'fa-twitter-square',
 238        'fa-facebook-square',
 239        'fa-camera-retro',
 240        'fa-key',
 241        'fa-cogs',
 242        'fa-comments',
 243        'fa-thumbs-o-up',
 244        'fa-thumbs-o-down',
 245        'fa-star-half',
 246        'fa-heart-o',
 247        'fa-sign-out',
 248        'fa-linkedin-square',
 249        'fa-thumb-tack',
 250        'fa-external-link',
 251        'fa-sign-in',
 252        'fa-trophy',
 253        'fa-github-square',
 254        'fa-upload',
 255        'fa-lemon-o',
 256        'fa-phone',
 257        'fa-square-o',
 258        'fa-bookmark-o',
 259        'fa-phone-square',
 260        'fa-twitter',
 261        'fa-facebook',
 262        'fa-github',
 263        'fa-unlock',
 264        'fa-credit-card',
 265        'fa-rss',
 266        'fa-hdd-o',
 267        'fa-bullhorn',
 268        'fa-bell',
 269        'fa-certificate',
 270        'fa-hand-o-right',
 271        'fa-hand-o-left',
 272        'fa-hand-o-up',
 273        'fa-hand-o-down',
 274        'fa-arrow-circle-left',
 275        'fa-arrow-circle-right',
 276        'fa-arrow-circle-up',
 277        'fa-arrow-circle-down',
 278        'fa-globe',
 279        'fa-wrench',
 280        'fa-tasks',
 281        'fa-filter',
 282        'fa-briefcase',
 283        'fa-arrows-alt',
 284        'fa-users',
 285        'fa-link',
 286        'fa-cloud',
 287        'fa-flask',
 288        'fa-scissors',
 289        'fa-files-o',
 290        'fa-paperclip',
 291        'fa-floppy-o',
 292        'fa-square',
 293        'fa-bars',
 294        'fa-list-ul',
 295        'fa-list-ol',
 296        'fa-strikethrough',
 297        'fa-underline',
 298        'fa-table',
 299        'fa-magic',
 300        'fa-truck',
 301        'fa-pinterest',
 302        'fa-pinterest-square',
 303        'fa-google-plus-square',
 304        'fa-google-plus',
 305        'fa-money',
 306        'fa-caret-down',
 307        'fa-caret-up',
 308        'fa-caret-left',
 309        'fa-caret-right',
 310        'fa-columns',
 311        'fa-sort',
 312        'fa-sort-asc',
 313        'fa-sort-desc',
 314        'fa-envelope',
 315        'fa-linkedin',
 316        'fa-undo',
 317        'fa-gavel',
 318        'fa-tachometer',
 319        'fa-comment-o',
 320        'fa-comments-o',
 321        'fa-bolt',
 322        'fa-sitemap',
 323        'fa-umbrella',
 324        'fa-clipboard',
 325        'fa-lightbulb-o',
 326        'fa-exchange',
 327        'fa-cloud-download',
 328        'fa-cloud-upload',
 329        'fa-user-md',
 330        'fa-stethoscope',
 331        'fa-suitcase',
 332        'fa-bell-o',
 333        'fa-coffee',
 334        'fa-cutlery',
 335        'fa-file-text-o',
 336        'fa-building-o',
 337        'fa-hospital-o',
 338        'fa-ambulance',
 339        'fa-medkit',
 340        'fa-fighter-jet',
 341        'fa-beer',
 342        'fa-h-square',
 343        'fa-plus-square',
 344        'fa-angle-double-left',
 345        'fa-angle-double-right',
 346        'fa-angle-double-up',
 347        'fa-angle-double-down',
 348        'fa-angle-left',
 349        'fa-angle-right',
 350        'fa-angle-up',
 351        'fa-angle-down',
 352        'fa-desktop',
 353        'fa-laptop',
 354        'fa-tablet',
 355        'fa-mobile',
 356        'fa-circle-o',
 357        'fa-quote-left',
 358        'fa-quote-right',
 359        'fa-spinner',
 360        'fa-circle',
 361        'fa-reply',
 362        'fa-github-alt',
 363        'fa-folder-o',
 364        'fa-folder-open-o',
 365        'fa-smile-o',
 366        'fa-frown-o',
 367        'fa-meh-o',
 368        'fa-gamepad',
 369        'fa-keyboard-o',
 370        'fa-flag-o',
 371        'fa-flag-checkered',
 372        'fa-terminal',
 373        'fa-code',
 374        'fa-reply-all',
 375        'fa-mail-reply-all',
 376        'fa-star-half-o',
 377        'fa-location-arrow',
 378        'fa-crop',
 379        'fa-code-fork',
 380        'fa-chain-broken',
 381        'fa-question',
 382        'fa-info',
 383        'fa-exclamation',
 384        'fa-superscript',
 385        'fa-subscript',
 386        'fa-eraser',
 387        'fa-puzzle-piece',
 388        'fa-microphone',
 389        'fa-microphone-slash',
 390        'fa-shield',
 391        'fa-calendar-o',
 392        'fa-fire-extinguisher',
 393        'fa-rocket',
 394        'fa-maxcdn',
 395        'fa-chevron-circle-left',
 396        'fa-chevron-circle-right',
 397        'fa-chevron-circle-up',
 398        'fa-chevron-circle-down',
 399        'fa-html5',
 400        'fa-css3',
 401        'fa-anchor',
 402        'fa-unlock-alt',
 403        'fa-bullseye',
 404        'fa-ellipsis-h',
 405        'fa-ellipsis-v',
 406        'fa-rss-square',
 407        'fa-play-circle',
 408        'fa-ticket',
 409        'fa-minus-square',
 410        'fa-minus-square-o',
 411        'fa-level-up',
 412        'fa-level-down',
 413        'fa-check-square',
 414        'fa-pencil-square',
 415        'fa-external-link-square',
 416        'fa-share-square',
 417        'fa-compass',
 418        'fa-caret-square-o-down',
 419        'fa-caret-square-o-up',
 420        'fa-caret-square-o-right',
 421        'fa-eur',
 422        'fa-gbp',
 423        'fa-usd',
 424        'fa-inr',
 425        'fa-jpy',
 426        'fa-rub',
 427        'fa-krw',
 428        'fa-btc',
 429        'fa-file',
 430        'fa-file-text',
 431        'fa-sort-alpha-asc',
 432        'fa-sort-alpha-desc',
 433        'fa-sort-amount-asc',
 434        'fa-sort-amount-desc',
 435        'fa-sort-numeric-asc',
 436        'fa-sort-numeric-desc',
 437        'fa-thumbs-up',
 438        'fa-thumbs-down',
 439        'fa-youtube-square',
 440        'fa-youtube',
 441        'fa-xing',
 442        'fa-xing-square',
 443        'fa-youtube-play',
 444        'fa-dropbox',
 445        'fa-stack-overflow',
 446        'fa-instagram',
 447        'fa-flickr',
 448        'fa-adn',
 449        'fa-bitbucket',
 450        'fa-bitbucket-square',
 451        'fa-tumblr',
 452        'fa-tumblr-square',
 453        'fa-long-arrow-down',
 454        'fa-long-arrow-up',
 455        'fa-long-arrow-left',
 456        'fa-long-arrow-right',
 457        'fa-apple',
 458        'fa-windows',
 459        'fa-android',
 460        'fa-linux',
 461        'fa-dribbble',
 462        'fa-skype',
 463        'fa-foursquare',
 464        'fa-trello',
 465        'fa-female',
 466        'fa-male',
 467        'fa-gittip',
 468        'fa-sun-o',
 469        'fa-moon-o',
 470        'fa-archive',
 471        'fa-bug',
 472        'fa-vk',
 473        'fa-weibo',
 474        'fa-renren',
 475        'fa-pagelines',
 476        'fa-stack-exchange',
 477        'fa-arrow-circle-o-right',
 478        'fa-arrow-circle-o-left',
 479        'fa-caret-square-o-left',
 480        'fa-dot-circle-o',
 481        'fa-wheelchair',
 482        'fa-vimeo-square',
 483        'fa-try',
 484        'fa-plus-square-o',
 485        'fa-space-shuttle',
 486        'fa-slack',
 487        'fa-envelope-square',
 488        'fa-wordpress',
 489        'fa-openid',
 490        'fa-institution',
 491        'fa-bank',
 492        'fa-university',
 493        'fa-mortar-board',
 494        'fa-graduation-cap',
 495        'fa-yahoo',
 496        'fa-google',
 497        'fa-reddit',
 498        'fa-reddit-square',
 499        'fa-stumbleupon-circle',
 500        'fa-stumbleupon',
 501        'fa-delicious',
 502        'fa-digg',
 503        'fa-pied-piper-square',
 504        'fa-pied-piper',
 505        'fa-pied-piper-alt',
 506        'fa-drupal',
 507        'fa-joomla',
 508        'fa-language',
 509        'fa-fax',
 510        'fa-building',
 511        'fa-child',
 512        'fa-paw',
 513        'fa-spoon',
 514        'fa-cube',
 515        'fa-cubes',
 516        'fa-behance',
 517        'fa-behance-square',
 518        'fa-steam',
 519        'fa-steam-square',
 520        'fa-recycle',
 521        'fa-automobile',
 522        'fa-car',
 523        'fa-cab',
 524        'fa-tree',
 525        'fa-spotify',
 526        'fa-deviantart',
 527        'fa-soundcloud',
 528        'fa-database',
 529        'fa-file-pdf-o',
 530        'fa-file-word-o',
 531        'fa-file-excel-o',
 532        'fa-file-powerpoint-o',
 533        'fa-file-photo-o',
 534        'fa-file-picture-o',
 535        'fa-file-image-o',
 536        'fa-file-zip-o',
 537        'fa-file-archive-o',
 538        'fa-file-sound-o',
 539        'fa-file-movie-o',
 540        'fa-file-code-o',
 541        'fa-vine',
 542        'fa-codepen',
 543        'fa-jsfiddle',
 544        'fa-life-bouy',
 545        'fa-support',
 546        'fa-life-ring',
 547        'fa-circle-o-notch',
 548        'fa-rebel',
 549        'fa-empire',
 550        'fa-git-square',
 551        'fa-git',
 552        'fa-hacker-news',
 553        'fa-tencent-weibo',
 554        'fa-qq',
 555        'fa-wechat',
 556        'fa-send',
 557        'fa-paper-plane',
 558        'fa-send-o',
 559        'fa-paper-plane-o',
 560        'fa-history',
 561        'fa-circle-thin',
 562        'fa-header',
 563        'fa-paragraph',
 564        'fa-sliders',
 565        'fa-share-alt',
 566        'fa-share-alt-square',
 567        'fa-bomb',
 568        'fa-soccer-ball',
 569        'fa-futbol-o',
 570        'fa-tty',
 571        'fa-binoculars',
 572        'fa-plug',
 573        'fa-slideshare',
 574        'fa-twitch',
 575        'fa-yelp',
 576        'fa-newspaper-o',
 577        'fa-wifi',
 578        'fa-calculator',
 579        'fa-paypal',
 580        'fa-google-wallet',
 581        'fa-cc-visa',
 582        'fa-cc-mastercard',
 583        'fa-cc-discover',
 584        'fa-cc-amex',
 585        'fa-cc-paypal',
 586        'fa-cc-stripe',
 587        'fa-bell-slash',
 588        'fa-bell-slash-o',
 589        'fa-trash',
 590        'fa-copyright',
 591        'fa-at',
 592        'fa-eyedropper',
 593        'fa-paint-brush',
 594        'fa-birthday-cake',
 595        'fa-area-chart',
 596        'fa-pie-chart',
 597        'fa-line-chart',
 598        'fa-lastfm',
 599        'fa-lastfm-square',
 600        'fa-toggle-off',
 601        'fa-toggle-on',
 602        'fa-bicycle',
 603        'fa-bus',
 604        'fa-ioxhost',
 605        'fa-angellist',
 606        'fa-cc',
 607        'fa-shekel',
 608        'fa-sheqel',
 609        'fa-ils',
 610        'fa-meanpath',
 611      );
 612    }
 613  
 614    public static function getFontIconColors() {
 615      return array(
 616        'bluegrey',
 617        'white',
 618        'red',
 619        'orange',
 620        'yellow',
 621        'green',
 622        'blue',
 623        'sky',
 624        'indigo',
 625        'violet',
 626        'pink',
 627        'lightgreytext',
 628        'lightbluetext',
 629      );
 630    }
 631  
 632  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1