Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98473224
PhabricatorFileSideNavView.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
Mon, Jan 13, 12:52
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Jan 15, 12:52 (2 d)
Engine
blob
Format
Raw Data
Handle
23588003
Attached To
rPH Phabricator
PhabricatorFileSideNavView.php
View Options
<?php
/*
* Copyright 2011 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.
*/
final
class
PhabricatorFileSideNavView
extends
AphrontView
{
private
$selectedFilter
;
public
function
setSelectedFilter
(
$selected_filter
)
{
$this
->
selectedFilter
=
$selected_filter
;
return
$this
;
}
private
function
getSelectedFilter
()
{
return
$this
->
selectedFilter
;
}
public
function
render
()
{
$selected_filter
=
$this
->
getSelectedFilter
();
if
(!
$selected_filter
)
{
throw
new
Exception
(
"Call setFilter() before render()!"
);
}
$filters
=
array
(
'Files'
=>
array
(),
'upload'
=>
array
(
'name'
=>
'Upload File'
,
'href'
=>
'/file/filter/upload/'
),
'my'
=>
array
(
'name'
=>
'My Files'
,
'href'
=>
'/file/filter/my/'
),
'all'
=>
array
(
'name'
=>
'All Files'
,
'href'
=>
'/file/filter/all/'
),
'<hr />'
=>
array
(),
'Image Macros'
=>
array
(),
'create_macro'
=>
array
(
'name'
=>
'Create Image Macro'
,
'href'
=>
'/file/macro/edit/'
),
'all_macros'
=>
array
(
'name'
=>
'All Image Macros'
,
'href'
=>
'/file/macro/'
),
);
$side_nav
=
new
AphrontSideNavView
();
foreach
(
$filters
as
$filter_key
=>
$filter
)
{
// more of a label than a filter
if
(
empty
(
$filter
))
{
$side_nav
->
addNavItem
(
phutil_render_tag
(
'span'
,
array
(),
$filter_key
));
continue
;
}
$selected
=
$filter_key
==
$selected_filter
;
$side_nav
->
addNavItem
(
phutil_render_tag
(
'a'
,
array
(
'href'
=>
$filter
[
'href'
],
'class'
=>
$selected
?
'aphront-side-nav-selected'
:
null
,
),
$filter
[
'name'
])
);
}
$side_nav
->
appendChild
(
$this
->
renderChildren
());
return
$side_nav
->
render
();
}
}
Event Timeline
Log In to Comment