@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
3final class PhabricatorProjectConfigOptions
4 extends PhabricatorApplicationConfigOptions {
5
6 public function getName() {
7 return pht('Projects');
8 }
9
10 public function getDescription() {
11 return pht('Configure Projects.');
12 }
13
14 public function getIcon() {
15 return 'fa-briefcase';
16 }
17
18 public function getGroup() {
19 return 'apps';
20 }
21
22 public function getApplicationClassName() {
23 return PhabricatorProjectApplication::class;
24 }
25
26 public function getOptions() {
27 $default_icons = PhabricatorProjectIconSet::getDefaultConfiguration();
28 $icons_type = 'project.icons';
29
30 $icons_description = $this->deformat(pht(<<<EOTEXT
31Allows you to change and customize the available project icons.
32
33You can find a list of available icons in {nav UIExamples > Icons and Images}.
34
35Configure a list of icon specifications. Each icon specification should be
36a dictionary, which may contain these keys:
37
38 - `key` //Required string.// Internal key identifying the icon.
39 - `name` //Required string.// Human-readable icon name.
40 - `icon` //Required string.// Specifies which actual icon image to use.
41 - `image` //Optional string.// Selects a default image. Select an image from
42 `resources/builtins/projects/`.
43 - `default` //Optional bool.// Selects a default icon. Exactly one icon must
44 be selected as the default.
45 - `disabled` //Optional bool.// If true, this icon will no longer be
46 available for selection when creating or editing projects.
47 - `special` //Optional string.// Marks an icon as a special icon:
48 - `milestone` This is the icon for milestones. Exactly one icon must be
49 selected as the milestone icon.
50
51You can look at the default configuration below for an example of a valid
52configuration.
53EOTEXT
54 ));
55
56 $default_colors = PhabricatorProjectIconSet::getDefaultColorMap();
57 $colors_type = 'project.colors';
58
59 $colors_description = $this->deformat(pht(<<<EOTEXT
60Allows you to relabel project colors.
61
62The list of available colors can not be expanded, but the existing colors may
63be given labels.
64
65Configure a list of color specifications. Each color specification should be a
66dictionary, which may contain these keys:
67
68 - `key` //Required string.// The internal key identifying the color.
69 - `name` //Required string.// Human-readable label for the color.
70 - `default` //Optional bool.// Selects the default color used when creating
71 new projects. Exactly one color must be selected as the default.
72
73You can look at the default configuration below for an example of a valid
74configuration.
75EOTEXT
76 ));
77
78 $default_fields = array(
79 'std:project:internal:description' => true,
80 );
81
82 foreach ($default_fields as $key => $enabled) {
83 $default_fields[$key] = array(
84 'disabled' => !$enabled,
85 );
86 }
87
88 $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
89
90
91 $subtype_type = 'projects.subtypes';
92 $subtype_default_key = PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT;
93 $subtype_example = array(
94 array(
95 'key' => $subtype_default_key,
96 'name' => pht('Project'),
97 ),
98 array(
99 'key' => 'team',
100 'name' => pht('Team'),
101 ),
102 );
103 $subtype_example = id(new PhutilJSON())->encodeAsList($subtype_example);
104
105 $subtype_default = array(
106 array(
107 'key' => $subtype_default_key,
108 'name' => pht('Project'),
109 ),
110 );
111
112 $fields_description = $this->deformat(pht(<<<EOTEXT
113List of custom fields for project tags.
114
115For details on adding new fields, see [[ %s | %s ]] in the
116documentation.
117EOTEXT
118 ,
119 PhabricatorEnv::getDoclink('Configuring Custom Fields'),
120 pht('Configuring Custom Fields')));
121
122 $subtype_description = $this->deformat(pht(<<<EOTEXT
123Allows you to define project subtypes. For a more detailed description of
124subtype configuration, see @{config:maniphest.subtypes}.
125EOTEXT
126 ));
127
128 return array(
129 $this->newOption('projects.custom-field-definitions', 'wild', array())
130 ->setSummary(pht('Custom Projects fields.'))
131 ->setDescription($fields_description)
132 ->addExample(
133 '{"mycompany:motto": {"name": "Project Motto", '.
134 '"type": "text"}}',
135 pht('Valid Setting')),
136 $this->newOption('projects.fields', $custom_field_type, $default_fields)
137 ->setCustomData(id(new PhabricatorProject())->getCustomFieldBaseClass())
138 ->setDescription(pht('Select and reorder project fields.')),
139 $this->newOption('projects.icons', $icons_type, $default_icons)
140 ->setSummary(pht('Adjust project icons.'))
141 ->setDescription($icons_description),
142 $this->newOption('projects.colors', $colors_type, $default_colors)
143 ->setSummary(pht('Adjust project colors.'))
144 ->setDescription($colors_description),
145 $this->newOption('projects.subtypes', $subtype_type, $subtype_default)
146 ->setSummary(pht('Define project subtypes.'))
147 ->setDescription($subtype_description)
148 ->addExample($subtype_example, pht('Simple Subtypes')),
149
150 );
151 }
152
153}