Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / files / view / PhabricatorGlobalUploadTargetView.php
blob76aacbe36f1303c0ebd2f2f07ed0cf62fd5b2e46
1 <?php
3 /**
4 * IMPORTANT: If you use this, make sure to implement
6 * public function isGlobalDragAndDropUploadEnabled() {
7 * return true;
8 * }
10 * on the controller(s) that render this class...! This is necessary
11 * to make sure Quicksand works properly with the javascript in this
12 * UI.
14 final class PhabricatorGlobalUploadTargetView extends AphrontView {
16 private $showIfSupportedID;
17 private $hintText;
18 private $viewPolicy;
19 private $submitURI;
21 public function setShowIfSupportedID($show_if_supported_id) {
22 $this->showIfSupportedID = $show_if_supported_id;
23 return $this;
26 public function getShowIfSupportedID() {
27 return $this->showIfSupportedID;
30 public function setHintText($hint_text) {
31 $this->hintText = $hint_text;
32 return $this;
35 public function getHintText() {
36 return $this->hintText;
39 public function setViewPolicy($view_policy) {
40 $this->viewPolicy = $view_policy;
41 return $this;
44 public function getViewPolicy() {
45 return $this->viewPolicy;
48 public function setSubmitURI($submit_uri) {
49 $this->submitURI = $submit_uri;
50 return $this;
53 public function getSubmitURI() {
54 return $this->submitURI;
59 public function render() {
60 $viewer = $this->getViewer();
61 if (!$viewer->isLoggedIn()) {
62 return null;
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 (!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(),
95 ));
97 return phutil_tag(
98 'div',
99 array(
100 'id' => $instructions_id,
101 'class' => 'phabricator-global-upload-instructions',
102 'style' => 'display: none;',
104 $hint_text);