Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102463085
AphrontFormDragAndDropUploadControl.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
Fri, Feb 21, 00:08
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 23, 00:08 (2 d)
Engine
blob
Format
Raw Data
Handle
24326724
Attached To
rPH Phabricator
AphrontFormDragAndDropUploadControl.php
View Options
<?php
final
class
AphrontFormDragAndDropUploadControl
extends
AphrontFormControl
{
private
$activatedClass
;
public
function
__construct
()
{
$this
->
setControlID
(
celerity_generate_unique_node_id
());
$this
->
setControlStyle
(
'display: none;'
);
}
protected
function
getCustomControlClass
()
{
return
'aphront-form-drag-and-drop-upload'
;
}
public
function
setActivatedClass
(
$class
)
{
$this
->
activatedClass
=
$class
;
return
$this
;
}
protected
function
renderInput
()
{
require_celerity_resource
(
'aphront-attached-file-view-css'
);
$list_id
=
celerity_generate_unique_node_id
();
$files
=
$this
->
getValue
();
$value
=
array
();
if
(
$files
)
{
foreach
(
$files
as
$file
)
{
$view
=
new
AphrontAttachedFileView
();
$view
->
setFile
(
$file
);
$value
[
$file
->
getPHID
()]
=
array
(
'phid'
=>
$file
->
getPHID
(),
'html'
=>
$view
->
render
(),
);
}
}
Javelin
::
initBehavior
(
'aphront-drag-and-drop'
,
array
(
'control'
=>
$this
->
getControlID
(),
'name'
=>
$this
->
getName
(),
'value'
=>
nonempty
(
$value
,
null
),
'list'
=>
$list_id
,
'uri'
=>
'/file/dropupload/'
,
'activatedClass'
=>
$this
->
activatedClass
,
));
return
phutil_tag
(
'div'
,
array
(
'id'
=>
$list_id
,
'class'
=>
'aphront-form-drag-and-drop-file-list'
,
),
''
);
}
}
Event Timeline
Log In to Comment