Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F35155985
PhabricatorProjectEditIconController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
2 KB
Subscribers
None
PhabricatorProjectEditIconController.php
View Options
<?php
final
class
PhabricatorProjectEditIconController
extends
PhabricatorProjectController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$project
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$project
)
{
return
new
Aphront404Response
();
}
$view_uri
=
'/tag/'
.
$project
->
getPrimarySlug
().
'/'
;
$edit_uri
=
$this
->
getApplicationURI
(
'edit/'
.
$project
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$v_icon
=
$request
->
getStr
(
'icon'
);
$type_icon
=
PhabricatorProjectTransaction
::
TYPE_ICON
;
$xactions
=
array
(
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
$type_icon
)
->
setNewValue
(
$v_icon
));
$editor
=
id
(
new
PhabricatorProjectTransactionEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnMissingFields
(
true
)
->
setContinueOnNoEffect
(
true
);
$editor
->
applyTransactions
(
$project
,
$xactions
);
return
id
(
new
AphrontReloadResponse
())->
setURI
(
$edit_uri
);
}
require_celerity_resource
(
'project-icon-css'
);
Javelin
::
initBehavior
(
'phabricator-tooltips'
);
$project_icons
=
PhabricatorProjectIcon
::
getIconMap
();
$ii
=
0
;
$buttons
=
array
();
foreach
(
$project_icons
as
$icon
=>
$label
)
{
$view
=
id
(
new
PHUIIconView
())
->
setIconFont
(
$icon
.
' bluegrey'
);
$aural
=
javelin_tag
(
'span'
,
array
(
'aural'
=>
true
,
),
pht
(
'Choose "%s" Icon'
,
$label
));
if
(
$icon
==
$project
->
getIcon
())
{
$class_extra
=
' selected'
;
$tip
=
$label
.
pht
(
' - selected'
);
}
else
{
$class_extra
=
null
;
$tip
=
$label
;
}
$buttons
[]
=
javelin_tag
(
'button'
,
array
(
'class'
=>
'icon-button'
.
$class_extra
,
'name'
=>
'icon'
,
'value'
=>
$icon
,
'type'
=>
'submit'
,
'sigil'
=>
'has-tooltip'
,
'meta'
=>
array
(
'tip'
=>
$tip
,
)
),
array
(
$aural
,
$view
,
));
if
((++
$ii
%
4
)
==
0
)
{
$buttons
[]
=
phutil_tag
(
'br'
);
}
}
$buttons
=
phutil_tag
(
'div'
,
array
(
'class'
=>
'icon-grid'
,
),
$buttons
);
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Choose Project Icon'
))
->
appendChild
(
$buttons
)
->
addCancelButton
(
$edit_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Feb 2, 8:11 AM (2 h, 18 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c6/3b/394210c6413064d49c75c08fc867
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment