4 * IMPORTANT: If you use this, make sure to implement
6 * public function isGlobalDragAndDropUploadEnabled() {
10 * on the controller(s) that render this class...! This is necessary
11 * to make sure Quicksand works properly with the javascript in this
14 final class PhabricatorGlobalUploadTargetView
extends AphrontView
{
16 private $showIfSupportedID;
21 public function setShowIfSupportedID($show_if_supported_id) {
22 $this->showIfSupportedID
= $show_if_supported_id;
26 public function getShowIfSupportedID() {
27 return $this->showIfSupportedID
;
30 public function setHintText($hint_text) {
31 $this->hintText
= $hint_text;
35 public function getHintText() {
36 return $this->hintText
;
39 public function setViewPolicy($view_policy) {
40 $this->viewPolicy
= $view_policy;
44 public function getViewPolicy() {
45 return $this->viewPolicy
;
48 public function setSubmitURI($submit_uri) {
49 $this->submitURI
= $submit_uri;
53 public function getSubmitURI() {
54 return $this->submitURI
;
59 public function render() {
60 $viewer = $this->getViewer();
61 if (!$viewer->isLoggedIn()) {
65 $instructions_id = 'phabricator-global-drag-and-drop-upload-instructions';
67 require_celerity_resource('global-drag-and-drop-css');
69 $hint_text = $this->getHintText();
70 if ($hint_text === null ||
!strlen($hint_text)) {
71 $hint_text = "\xE2\x87\xAA ".pht('Drop Files to Upload');
74 // Use the configured default view policy. Drag and drop uploads use
75 // a more restrictive view policy if we don't specify a policy explicitly,
76 // as the more restrictive policy is correct for most drop targets (like
77 // Pholio uploads and Remarkup text areas).
79 $view_policy = $this->getViewPolicy();
80 if ($view_policy === null) {
81 $view_policy = PhabricatorFile
::initializeNewFile()->getViewPolicy();
84 $submit_uri = $this->getSubmitURI();
85 $done_uri = '/file/query/authored/';
87 Javelin
::initBehavior('global-drag-and-drop', array(
88 'ifSupported' => $this->showIfSupportedID
,
89 'instructions' => $instructions_id,
90 'uploadURI' => '/file/dropupload/',
91 'submitURI' => $submit_uri,
92 'browseURI' => $done_uri,
93 'viewPolicy' => $view_policy,
94 'chunkThreshold' => PhabricatorFileStorageEngine
::getChunkThreshold(),
100 'id' => $instructions_id,
101 'class' => 'phabricator-global-upload-instructions',
102 'style' => 'display: none;',