Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97995961
PhabricatorMacroMemeDialogController.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
Wed, Jan 8, 10:18
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Jan 10, 10:18 (2 d)
Engine
blob
Format
Raw Data
Handle
23475491
Attached To
rPH Phabricator
PhabricatorMacroMemeDialogController.php
View Options
<?php
final
class
PhabricatorMacroMemeDialogController
extends
PhabricatorMacroController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$phid
=
head
(
$request
->
getArr
(
'macro'
));
$above
=
$request
->
getStr
(
'above'
);
$below
=
$request
->
getStr
(
'below'
);
$e_macro
=
true
;
$errors
=
array
();
if
(
$request
->
isDialogFormPost
())
{
if
(!
$phid
)
{
$e_macro
=
pht
(
'Required'
);
$errors
[]
=
pht
(
'Macro name is required.'
);
}
else
{
$macro
=
id
(
new
PhabricatorMacroQuery
())
->
setViewer
(
$user
)
->
withPHIDs
(
array
(
$phid
))
->
executeOne
();
if
(!
$macro
)
{
$e_macro
=
pht
(
'Invalid'
);
$errors
[]
=
pht
(
'No such macro.'
);
}
}
if
(!
$errors
)
{
$options
=
new
PhutilSimpleOptions
();
$data
=
array
(
'src'
=>
$macro
->
getName
(),
'above'
=>
$above
,
'below'
=>
$below
,
);
$string
=
$options
->
unparse
(
$data
,
$escape
=
'}'
);
$result
=
array
(
'text'
=>
"{meme, {$string}}"
,
);
return
id
(
new
AphrontAjaxResponse
())->
setContent
(
$result
);
}
}
$view
=
id
(
new
PHUIFormLayoutView
())
->
appendChild
(
id
(
new
AphrontFormTokenizerControl
())
->
setLabel
(
pht
(
'Macro'
))
->
setName
(
'macro'
)
->
setLimit
(
1
)
->
setDatasource
(
'/typeahead/common/macros/'
)
->
setError
(
$e_macro
))
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'Above'
))
->
setName
(
'above'
)
->
setValue
(
$above
))
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'Below'
))
->
setName
(
'below'
)
->
setValue
(
$below
));
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setTitle
(
pht
(
'Create Meme'
))
->
appendChild
(
$view
)
->
addCancelButton
(
'/'
)
->
addSubmitButton
(
pht
(
'rofllolo!!~'
));
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment