Example #1
0
 /**
  * Get the descriptor of the fieldset that contains the file source
  * selection. The section is 'source'
  *
  * @return Array: descriptor array
  */
 protected function getSourceSection()
 {
     if ($this->mSessionKey) {
         return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash'));
     }
     $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser());
     $radio = $canUploadByUrl;
     $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
     $descriptor = array();
     if ($this->mTextTop) {
         $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
     }
     $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file');
     # Limit to upload_max_filesize unless we are running under HipHop and
     # that setting doesn't exist
     if (!wfIsHipHop()) {
         $this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size')));
     }
     $descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse() . ' ' . $this->msg('upload_source_file')->escaped(), 'checked' => $selectedSourceType == 'file');
     if ($canUploadByUrl) {
         $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url');
         $descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . ' ' . $this->msg('upload_source_url')->escaped(), 'checked' => $selectedSourceType == 'url');
     }
     wfRunHooks('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
     $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true);
     return $descriptor;
 }
Example #2
0
 /**
  * Get the descriptor of the fieldset that contains the file source
  * selection. The section is 'source'
  *
  * @return array Descriptor array
  */
 protected function getSourceSection()
 {
     if ($this->mSessionKey) {
         return array('SessionKey' => array('type' => 'hidden', 'default' => $this->mSessionKey), 'SourceType' => array('type' => 'hidden', 'default' => 'Stash'));
     }
     $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()) === true && $this->getConfig()->get('CopyUploadsFromSpecialUpload');
     $radio = $canUploadByUrl;
     $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
     $descriptor = array();
     if ($this->mTextTop) {
         $descriptor['UploadFormTextTop'] = array('type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true);
     }
     $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize('file');
     # Limit to upload_max_filesize unless we are running under HipHop and
     # that setting doesn't exist
     if (!wfIsHHVM()) {
         $this->mMaxUploadSize['file'] = min($this->mMaxUploadSize['file'], wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size')));
     }
     $help = $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse();
     // If the user can also upload by URL, there are 2 different file size limits.
     // This extra message helps stress which limit corresponds to what.
     if ($canUploadByUrl) {
         $help .= $this->msg('word-separator')->escaped();
         $help .= $this->msg('upload_source_file')->parse();
     }
     $descriptor['UploadFile'] = array('class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'radio-id' => 'wpSourceTypeFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $help, 'checked' => $selectedSourceType == 'file');
     if ($canUploadByUrl) {
         $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url');
         $descriptor['UploadFileURL'] = array('class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'radio-id' => 'wpSourceTypeurl', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . $this->msg('word-separator')->escaped() . $this->msg('upload_source_url')->parse(), 'checked' => $selectedSourceType == 'url');
     }
     Hooks::run('UploadFormSourceDescriptors', array(&$descriptor, &$radio, $selectedSourceType));
     $descriptor['Extensions'] = array('type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true);
     return $descriptor;
 }
Example #3
0
 /**
  * Get the descriptor of the fieldset that contains the file source
  * selection. The section is 'source'
  *
  * @return array Descriptor array
  */
 protected function getSourceSection()
 {
     if ($this->mSessionKey) {
         return ['SessionKey' => ['type' => 'hidden', 'default' => $this->mSessionKey], 'SourceType' => ['type' => 'hidden', 'default' => 'Stash']];
     }
     $canUploadByUrl = UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed($this->getUser()) === true && $this->getConfig()->get('CopyUploadsFromSpecialUpload');
     $radio = $canUploadByUrl;
     $selectedSourceType = strtolower($this->getRequest()->getText('wpSourceType', 'File'));
     $descriptor = [];
     if ($this->mTextTop) {
         $descriptor['UploadFormTextTop'] = ['type' => 'info', 'section' => 'source', 'default' => $this->mTextTop, 'raw' => true];
     }
     $this->mMaxUploadSize['file'] = min(UploadBase::getMaxUploadSize('file'), UploadBase::getMaxPhpUploadSize());
     $help = $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['file']))->parse();
     // If the user can also upload by URL, there are 2 different file size limits.
     // This extra message helps stress which limit corresponds to what.
     if ($canUploadByUrl) {
         $help .= $this->msg('word-separator')->escaped();
         $help .= $this->msg('upload_source_file')->parse();
     }
     $descriptor['UploadFile'] = ['class' => 'UploadSourceField', 'section' => 'source', 'type' => 'file', 'id' => 'wpUploadFile', 'radio-id' => 'wpSourceTypeFile', 'label-message' => 'sourcefilename', 'upload-type' => 'File', 'radio' => &$radio, 'help' => $help, 'checked' => $selectedSourceType == 'file'];
     if ($canUploadByUrl) {
         $this->mMaxUploadSize['url'] = UploadBase::getMaxUploadSize('url');
         $descriptor['UploadFileURL'] = ['class' => 'UploadSourceField', 'section' => 'source', 'id' => 'wpUploadFileURL', 'radio-id' => 'wpSourceTypeurl', 'label-message' => 'sourceurl', 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg('upload-maxfilesize', $this->getContext()->getLanguage()->formatSize($this->mMaxUploadSize['url']))->parse() . $this->msg('word-separator')->escaped() . $this->msg('upload_source_url')->parse(), 'checked' => $selectedSourceType == 'url'];
     }
     Hooks::run('UploadFormSourceDescriptors', [&$descriptor, &$radio, $selectedSourceType]);
     $descriptor['Extensions'] = ['type' => 'info', 'section' => 'source', 'default' => $this->getExtensionsMessage(), 'raw' => true];
     return $descriptor;
 }