Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99498879
PhabricatorDashboardPanelTabsCustomField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 25, 00:58
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 27, 00:58 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23805866
Attached To
rPH Phabricator
PhabricatorDashboardPanelTabsCustomField.php
View Options
<?php
final
class
PhabricatorDashboardPanelTabsCustomField
extends
PhabricatorStandardCustomField
{
public
function
getFieldType
()
{
return
'dashboard.tabs'
;
}
public
function
shouldAppearInApplicationSearch
()
{
return
false
;
}
public
function
readValueFromRequest
(
AphrontRequest
$request
)
{
$value
=
array
();
$names
=
$request
->
getArr
(
$this
->
getFieldKey
().
'_name'
);
$panels
=
$request
->
getArr
(
$this
->
getFieldKey
().
'_panelID'
);
foreach
(
$names
as
$idx
=>
$name
)
{
$panel_id
=
idx
(
$panels
,
$idx
);
if
(
strlen
(
$name
)
&&
$panel_id
)
{
$value
[]
=
array
(
'name'
=>
$name
,
'panelID'
=>
$panel_id
,
);
}
}
$this
->
setFieldValue
(
$value
);
}
public
function
renderEditControl
(
array
$handles
)
{
$panels
=
id
(
new
PhabricatorDashboardPanelQuery
())
->
setViewer
(
$this
->
getViewer
())
->
execute
();
$panel_map
=
array
();
foreach
(
$panels
as
$panel
)
{
$panel_map
[
$panel
->
getID
()]
=
pht
(
'%s %s'
,
$panel
->
getMonogram
(),
$panel
->
getName
());
}
$panel_map
=
array
(
''
=>
pht
(
'(None)'
),
)
+
$panel_map
;
$value
=
$this
->
getFieldValue
();
if
(!
is_array
(
$value
))
{
$value
=
array
();
}
$out
=
array
();
for
(
$ii
=
1
;
$ii
<=
6
;
$ii
++)
{
$tab
=
idx
(
$value
,
(
$ii
-
1
),
array
());
$out
[]
=
id
(
new
AphrontFormTextControl
())
->
setName
(
$this
->
getFieldKey
().
'_name[]'
)
->
setValue
(
idx
(
$tab
,
'name'
))
->
setLabel
(
pht
(
'Tab %d Name'
,
$ii
));
$out
[]
=
id
(
new
AphrontFormSelectControl
())
->
setName
(
$this
->
getFieldKey
().
'_panelID[]'
)
->
setValue
(
idx
(
$tab
,
'panelID'
))
->
setOptions
(
$panel_map
)
->
setLabel
(
pht
(
'Tab %d Panel'
,
$ii
));
}
return
$out
;
}
}
Event Timeline
Log In to Comment