Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F108071950
PhamePostListController.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
Sun, Apr 13, 22:12
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Apr 15, 22:12 (2 d)
Engine
blob
Format
Raw Data
Handle
25518400
Attached To
rPH Phabricator
PhamePostListController.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final
class
PhamePostListController
extends
PhameController
{
private
$bloggername
;
private
$filter
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
filter
=
idx
(
$data
,
'filter'
,
'blogger'
);
$this
->
bloggername
=
idx
(
$data
,
'bloggername'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$query
=
id
(
new
PhamePostQuery
())
->
setViewer
(
$user
);
switch
(
$this
->
filter
)
{
case
'draft'
:
$query
->
withBloggerPHIDs
(
array
(
$user
->
getPHID
()));
$query
->
withVisibility
(
PhamePost
::
VISIBILITY_DRAFT
);
$nodata
=
pht
(
'You have no unpublished drafts.'
);
$title
=
pht
(
'Unpublished Drafts'
);
break
;
case
'blogger'
:
if
(
$this
->
bloggername
)
{
$blogger
=
id
(
new
PhabricatorUser
())->
loadOneWhere
(
'username = %s'
,
$this
->
bloggername
);
if
(!
$blogger
)
{
return
new
Aphront404Response
();
}
}
else
{
$blogger
=
$user
;
}
$query
->
withBloggerPHIDs
(
array
(
$blogger
->
getPHID
()));
if
(
$blogger
->
getPHID
()
==
$user
->
getPHID
())
{
$nodata
=
pht
(
'You have not written any posts.'
);
}
else
{
$nodata
=
pht
(
'%s has not written any posts.'
,
$blogger
);
}
$title
=
pht
(
'Posts By %s'
,
$blogger
);
break
;
case
'all'
:
$nodata
=
pht
(
'There are no visible posts.'
);
$title
=
pht
(
'Posts'
);
break
;
default
:
throw
new
Exception
(
"Unknown filter '{$this->filter}'!"
);
}
$pager
=
id
(
new
AphrontCursorPagerView
())
->
readFromRequest
(
$request
);
$posts
=
$query
->
executeWithCursorPager
(
$pager
);
$handle_phids
=
array_merge
(
mpull
(
$posts
,
'getBloggerPHID'
),
mpull
(
$posts
,
'getBlogPHID'
));
$this
->
loadHandles
(
$handle_phids
);
$header
=
id
(
new
PhabricatorHeaderView
())
->
setHeader
(
$title
);
$post_list
=
$this
->
renderPostList
(
$posts
,
$user
,
$nodata
);
$nav
=
$this
->
renderSideNavFilterView
(
null
);
$nav
->
appendChild
(
array
(
$header
,
$post_list
,
));
return
$this
->
buildApplicationPage
(
$nav
,
array
(
'title'
=>
$title
,
'device'
=>
true
,
));
}
}
Event Timeline
Log In to Comment