@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<?php
2
3abstract class PhabricatorSyntaxStyle extends Phobject {
4
5 abstract public function getStyleName();
6 abstract public function getStyleMap();
7
8 final public function getStyleOrder() {
9 return (string)id(new PhutilSortVector())
10 ->addInt($this->isDefaultStyle() ? 0 : 1)
11 ->addString($this->getStyleName());
12 }
13
14 final public function getSyntaxStyleKey() {
15 return $this->getPhobjectClassConstant('STYLEKEY');
16 }
17
18 final public function isDefaultStyle() {
19 return ($this->getSyntaxStyleKey() == 'default');
20 }
21
22 public static function getAllStyles() {
23 return id(new PhutilClassMapQuery())
24 ->setAncestorClass(self::class)
25 ->setUniqueMethod('getSyntaxStyleKey')
26 ->setSortMethod('getStyleName')
27 ->execute();
28 }
29
30 final public function getRemarkupStyleMap() {
31 $map = array(
32 'rbw_r' => 'color: red',
33 'rbw_o' => 'color: orange',
34 'rbw_y' => 'color: yellow',
35 'rbw_g' => 'color: green',
36 'rbw_b' => 'color: blue',
37 'rbw_i' => 'color: indigo',
38 'rbw_v' => 'color: violet',
39 );
40
41 return $map + $this->getStyleMap();
42 }
43
44}