Path: blob/master/src/applications/files/view/PhabricatorGlobalUploadTargetView.php
12242 views
<?php12/**3* IMPORTANT: If you use this, make sure to implement4*5* public function isGlobalDragAndDropUploadEnabled() {6* return true;7* }8*9* on the controller(s) that render this class...! This is necessary10* to make sure Quicksand works properly with the javascript in this11* UI.12*/13final class PhabricatorGlobalUploadTargetView extends AphrontView {1415private $showIfSupportedID;16private $hintText;17private $viewPolicy;18private $submitURI;1920public function setShowIfSupportedID($show_if_supported_id) {21$this->showIfSupportedID = $show_if_supported_id;22return $this;23}2425public function getShowIfSupportedID() {26return $this->showIfSupportedID;27}2829public function setHintText($hint_text) {30$this->hintText = $hint_text;31return $this;32}3334public function getHintText() {35return $this->hintText;36}3738public function setViewPolicy($view_policy) {39$this->viewPolicy = $view_policy;40return $this;41}4243public function getViewPolicy() {44return $this->viewPolicy;45}4647public function setSubmitURI($submit_uri) {48$this->submitURI = $submit_uri;49return $this;50}5152public function getSubmitURI() {53return $this->submitURI;54}55565758public function render() {59$viewer = $this->getViewer();60if (!$viewer->isLoggedIn()) {61return null;62}6364$instructions_id = 'phabricator-global-drag-and-drop-upload-instructions';6566require_celerity_resource('global-drag-and-drop-css');6768$hint_text = $this->getHintText();69if ($hint_text === null || !strlen($hint_text)) {70$hint_text = "\xE2\x87\xAA ".pht('Drop Files to Upload');71}7273// Use the configured default view policy. Drag and drop uploads use74// a more restrictive view policy if we don't specify a policy explicitly,75// as the more restrictive policy is correct for most drop targets (like76// Pholio uploads and Remarkup text areas).7778$view_policy = $this->getViewPolicy();79if ($view_policy === null) {80$view_policy = PhabricatorFile::initializeNewFile()->getViewPolicy();81}8283$submit_uri = $this->getSubmitURI();84$done_uri = '/file/query/authored/';8586Javelin::initBehavior('global-drag-and-drop', array(87'ifSupported' => $this->showIfSupportedID,88'instructions' => $instructions_id,89'uploadURI' => '/file/dropupload/',90'submitURI' => $submit_uri,91'browseURI' => $done_uri,92'viewPolicy' => $view_policy,93'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(),94));9596return phutil_tag(97'div',98array(99'id' => $instructions_id,100'class' => 'phabricator-global-upload-instructions',101'style' => 'display: none;',102),103$hint_text);104}105}106107108