Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2895947
PhabricatorEditEngineConfigurationSearchEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
4 KB
Referenced Files
None
Subscribers
None
PhabricatorEditEngineConfigurationSearchEngine.php
View Options
<?php
final
class
PhabricatorEditEngineConfigurationSearchEngine
extends
PhabricatorApplicationSearchEngine
{
private
$engineKey
;
public
function
setEngineKey
(
$engine_key
)
{
$this
->
engineKey
=
$engine_key
;
return
$this
;
}
public
function
getEngineKey
(
)
{
return
$this
->
engineKey
;
}
public
function
canUseInPanelContext
(
)
{
return
false
;
}
public
function
getResultTypeDescription
(
)
{
return
pht
(
'Forms'
)
;
}
public
function
getApplicationClassName
(
)
{
return
PhabricatorTransactionsApplication
::
class
;
}
public
function
newQuery
(
)
{
return
id
(
new
PhabricatorEditEngineConfigurationQuery
(
)
)
->
withEngineKeys
(
array
(
$this
->
getEngineKey
(
)
)
)
;
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
(
)
;
$is_create
=
$map
[
'isCreate'
]
;
if
(
$is_create
!==
null
)
{
$query
->
withIsDefault
(
$is_create
)
;
}
$is_edit
=
$map
[
'isEdit'
]
;
if
(
$is_edit
!==
null
)
{
$query
->
withIsEdit
(
$is_edit
)
;
}
return
$query
;
}
protected
function
buildCustomSearchFields
(
)
{
return
array
(
id
(
new
PhabricatorSearchThreeStateField
(
)
)
->
setLabel
(
pht
(
'Create'
)
)
->
setKey
(
'isCreate'
)
->
setOptions
(
pht
(
'Show All'
)
,
pht
(
'Hide Create Forms'
)
,
pht
(
'Show Only Create Forms'
)
)
,
id
(
new
PhabricatorSearchThreeStateField
(
)
)
->
setLabel
(
pht
(
'Edit'
)
)
->
setKey
(
'isEdit'
)
->
setOptions
(
pht
(
'Show All'
)
,
pht
(
'Hide Edit Forms'
)
,
pht
(
'Show Only Edit Forms'
)
)
,
)
;
}
protected
function
getDefaultFieldOrder
(
)
{
return
array
(
)
;
}
protected
function
getURI
(
$path
)
{
return
'/transactions/editengine/'
.
$this
->
getEngineKey
(
)
.
'/'
.
$path
;
}
protected
function
getBuiltinQueryNames
(
)
{
$names
=
array
(
'all'
=>
pht
(
'All Forms'
)
,
'create'
=>
pht
(
'Create Forms'
)
,
'modify'
=>
pht
(
'Edit Forms'
)
,
)
;
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
(
)
;
$query
->
setQueryKey
(
$query_key
)
;
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'create'
:
return
$query
->
setParameter
(
'isCreate'
,
true
)
;
case
'modify'
:
return
$query
->
setParameter
(
'isEdit'
,
true
)
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
)
;
}
protected
function
renderResultList
(
array
$configs
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$configs
,
'PhabricatorEditEngineConfiguration'
)
;
$viewer
=
$this
->
requireViewer
(
)
;
$engine_key
=
$this
->
getEngineKey
(
)
;
$list
=
id
(
new
PHUIObjectItemListView
(
)
)
->
setUser
(
$viewer
)
;
foreach
(
$configs
as
$config
)
{
$item
=
id
(
new
PHUIObjectItemView
(
)
)
->
setHeader
(
$config
->
getDisplayName
(
)
)
;
$id
=
$config
->
getID
(
)
;
if
(
$config
->
getIsDefault
(
)
)
{
$item
->
addAttribute
(
pht
(
'Default Create Form'
)
)
;
}
if
(
$config
->
getIsEdit
(
)
)
{
$item
->
addAttribute
(
pht
(
'Edit Form'
)
)
;
}
if
(
$config
->
getIsDisabled
(
)
)
{
$item
->
setDisabled
(
true
)
;
$item
->
setStatusIcon
(
'fa-ban grey'
,
pht
(
'Disabled'
)
)
;
}
else
{
$item
->
setStatusIcon
(
'fa-file-text-o green'
,
pht
(
'Enabled'
)
)
;
}
$subtype_key
=
$config
->
getSubtype
(
)
;
if
(
$subtype_key
!==
PhabricatorEditEngineSubtype
::
SUBTYPE_DEFAULT
)
{
$engine
=
$config
->
getEngine
(
)
;
if
(
$engine
->
supportsSubtypes
(
)
)
{
$map
=
$engine
->
newSubtypeMap
(
)
;
if
(
$map
->
isValidSubtype
(
$subtype_key
)
)
{
$subtype
=
$map
->
getSubtype
(
$subtype_key
)
;
$icon
=
$subtype
->
getIcon
(
)
;
$color
=
$subtype
->
getColor
(
)
;
$item
->
addIcon
(
"{$icon} {$color}"
,
$subtype
->
getName
(
)
)
;
}
}
}
if
(
$id
)
{
$item
->
setObjectName
(
pht
(
'Form %d'
,
$id
)
)
;
$key
=
$id
;
}
else
{
$item
->
addIcon
(
'fa-file-text bluegrey'
,
pht
(
'Builtin'
)
)
;
$key
=
$config
->
getBuiltinKey
(
)
;
}
$item
->
setHref
(
"/transactions/editengine/{$engine_key}/view/{$key}/"
)
;
$list
->
addItem
(
$item
)
;
}
return
id
(
new
PhabricatorApplicationSearchResultView
(
)
)
->
setObjectList
(
$list
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 22:20 (6 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129322
Default Alt Text
PhabricatorEditEngineConfigurationSearchEngine.php (4 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment