Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93117789
AphrontAbstractFormDragAndDropUploadControl.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
Tue, Nov 26, 08:23
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 08:23 (2 d)
Engine
blob
Format
Raw Data
Handle
22578571
Attached To
rPH Phabricator
AphrontAbstractFormDragAndDropUploadControl.php
View Options
<?php
abstract
class
AphrontAbstractFormDragAndDropUploadControl
extends
AphrontFormControl
{
private
$activatedClass
;
private
$uploadURI
=
'/file/dropupload/'
;
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
setUploadURI
(
$upload_uri
)
{
$this
->
uploadURI
=
$upload_uri
;
return
$this
;
}
public
function
getUploadURI
()
{
return
$this
->
uploadURI
;
}
public
function
setActivatedClass
(
$class
)
{
$this
->
activatedClass
=
$class
;
return
$this
;
}
protected
function
getFileView
()
{
return
new
AphrontAttachedFileView
();
}
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
=
$this
->
getFileView
();
$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'
=>
$this
->
getUploadURI
(),
'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