Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896798
PhameBlogSearchEngine.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
2 KB
Referenced Files
None
Subscribers
None
PhameBlogSearchEngine.php
View Options
<?php
final
class
PhameBlogSearchEngine
extends
PhabricatorApplicationSearchEngine
{
public
function
getResultTypeDescription
(
)
{
return
pht
(
'Phame Blogs'
)
;
}
public
function
getApplicationClassName
(
)
{
return
PhabricatorPhameApplication
::
class
;
}
public
function
newQuery
(
)
{
return
id
(
new
PhameBlogQuery
(
)
)
->
needProfileImage
(
true
)
;
}
protected
function
buildQueryFromParameters
(
array
$map
)
{
$query
=
$this
->
newQuery
(
)
;
if
(
$map
[
'statuses'
]
)
{
$query
->
withStatuses
(
array
(
$map
[
'statuses'
]
)
)
;
}
return
$query
;
}
protected
function
buildCustomSearchFields
(
)
{
return
array
(
id
(
new
PhabricatorSearchSelectField
(
)
)
->
setKey
(
'statuses'
)
->
setLabel
(
pht
(
'Status'
)
)
->
setOptions
(
array
(
''
=>
pht
(
'All'
)
,
PhameBlog
::
STATUS_ACTIVE
=>
pht
(
'Active'
)
,
PhameBlog
::
STATUS_ARCHIVED
=>
pht
(
'Archived'
)
,
)
)
,
)
;
}
protected
function
getURI
(
$path
)
{
return
'/phame/blog/'
.
$path
;
}
protected
function
getBuiltinQueryNames
(
)
{
$names
=
array
(
'active'
=>
pht
(
'Active Blogs'
)
,
'archived'
=>
pht
(
'Archived Blogs'
)
,
'all'
=>
pht
(
'All Blogs'
)
,
)
;
return
$names
;
}
public
function
buildSavedQueryFromBuiltin
(
$query_key
)
{
$query
=
$this
->
newSavedQuery
(
)
;
$query
->
setQueryKey
(
$query_key
)
;
switch
(
$query_key
)
{
case
'all'
:
return
$query
;
case
'active'
:
return
$query
->
setParameter
(
'statuses'
,
PhameBlog
::
STATUS_ACTIVE
)
;
case
'archived'
:
return
$query
->
setParameter
(
'statuses'
,
PhameBlog
::
STATUS_ARCHIVED
)
;
}
return
parent
::
buildSavedQueryFromBuiltin
(
$query_key
)
;
}
protected
function
renderResultList
(
array
$blogs
,
PhabricatorSavedQuery
$query
,
array
$handles
)
{
assert_instances_of
(
$blogs
,
'PhameBlog'
)
;
$viewer
=
$this
->
requireViewer
(
)
;
$list
=
new
PHUIObjectItemListView
(
)
;
$list
->
setUser
(
$viewer
)
;
foreach
(
$blogs
as
$blog
)
{
$id
=
$blog
->
getID
(
)
;
if
(
$blog
->
getDomain
(
)
)
{
$domain
=
$blog
->
getDomain
(
)
;
}
else
{
$domain
=
pht
(
'Local Blog'
)
;
}
$item
=
id
(
new
PHUIObjectItemView
(
)
)
->
setUser
(
$viewer
)
->
setObject
(
$blog
)
->
setHeader
(
$blog
->
getName
(
)
)
->
setImageURI
(
$blog
->
getProfileImageURI
(
)
)
->
setDisabled
(
$blog
->
isArchived
(
)
)
->
setHref
(
$this
->
getApplicationURI
(
"/blog/view/{$id}/"
)
)
->
addAttribute
(
$domain
)
;
if
(
!
$blog
->
isArchived
(
)
)
{
$button
=
id
(
new
PHUIButtonView
(
)
)
->
setTag
(
'a'
)
->
setText
(
'New Post'
)
->
setHref
(
$this
->
getApplicationURI
(
'/post/edit/?blog='
.
$id
)
)
->
setButtonType
(
PHUIButtonView
::
BUTTONTYPE_SIMPLE
)
;
$item
->
setSideColumn
(
$button
)
;
}
$list
->
addItem
(
$item
)
;
}
$result
=
new
PhabricatorApplicationSearchResultView
(
)
;
$result
->
setObjectList
(
$list
)
;
$result
->
setNoDataString
(
pht
(
'No blogs found.'
)
)
;
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 23:35 (6 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129965
Default Alt Text
PhameBlogSearchEngine.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment