当前位置: 首页>>代码示例>>PHP>>正文


PHP AphrontRequest::getFileExists方法代码示例

本文整理汇总了PHP中AphrontRequest::getFileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::getFileExists方法的具体用法?PHP AphrontRequest::getFileExists怎么用?PHP AphrontRequest::getFileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AphrontRequest的用法示例。


在下文中一共展示了AphrontRequest::getFileExists方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readRequest

 public function readRequest(PhabricatorConfigOption $option, AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $view_policy = PhabricatorPolicies::POLICY_PUBLIC;
     if ($request->getBool('removeLogo')) {
         $logo_image_phid = null;
     } else {
         if ($request->getFileExists('logoImage')) {
             $logo_image = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'logoImage'), array('name' => 'logo', 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'canCDN' => true, 'isExplicitUpload' => true));
             $logo_image_phid = $logo_image->getPHID();
         } else {
             $logo_image_phid = self::getLogoImagePHID();
         }
     }
     $wordmark_text = $request->getStr('wordmarkText');
     $value = array('logoImagePHID' => $logo_image_phid, 'wordmarkText' => $wordmark_text);
     $errors = array();
     $e_value = null;
     try {
         $this->validateOption($option, $value);
     } catch (Exception $ex) {
         $e_value = pht('Invalid');
         $errors[] = $ex->getMessage();
         $value = array();
     }
     return array($e_value, $errors, $value, phutil_json_encode($value));
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:27,代码来源:PhabricatorCustomLogoConfigType.php

示例2: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $file = PhabricatorFile::initializeNewFile();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $view_policy = $request->getStr('viewPolicy');
         if (!$request->getFileExists('file')) {
             $e_file = pht('Required');
             $errors[] = pht('You must select a file to upload.');
         } else {
             $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true));
         }
         if (!$errors) {
             return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
         }
         $file->setViewPolicy($view_policy);
     }
     $support_id = celerity_generate_unique_node_id();
     $instructions = id(new AphrontFormMarkupControl())->setControlID($support_id)->setControlStyle('display: none')->setValue(hsprintf('<br /><br /><strong>%s</strong> %s<br /><br />', pht('Drag and Drop:'), pht('You can also upload files by dragging and dropping them from your ' . 'desktop onto this page or the Phabricator home page.')));
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($file)->execute();
     $form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setLabel(pht('File'))->setName('file')->setError($e_file))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name'))->setName('name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicyObject($file)->setPolicies($policies)->setName('viewPolicy'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload'))->addCancelButton('/file/'))->appendChild($instructions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Upload'), $request->getRequestURI());
     $crumbs->setBorder(true);
     $title = pht('Upload File');
     $global_upload = id(new PhabricatorGlobalUploadTargetView())->setUser($viewer)->setShowIfSupportedID($support_id);
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('File'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-upload');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $global_upload));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:33,代码来源:PhabricatorFileUploadController.php

示例3: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $this->requireApplicationCapability(PhabricatorMacroManageCapability::CAPABILITY);
     $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW))->withIDs(array($id))->executeOne();
     if (!$macro) {
         return new Aphront404Response();
     }
     $errors = array();
     $view_uri = $this->getApplicationURI('/view/' . $macro->getID() . '/');
     $e_file = null;
     $file = null;
     if ($request->isFormPost()) {
         $xactions = array();
         if ($request->getBool('behaviorForm')) {
             $xactions[] = id(new PhabricatorMacroTransaction())->setTransactionType(PhabricatorMacroTransaction::TYPE_AUDIO_BEHAVIOR)->setNewValue($request->getStr('audioBehavior'));
         } else {
             $file = null;
             if ($request->getFileExists('file')) {
                 $file = PhabricatorFile::newFromPHPUpload($_FILES['file'], array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'isExplicitUpload' => true));
             }
             if ($file) {
                 if (!$file->isAudio()) {
                     $errors[] = pht('You must upload audio.');
                     $e_file = pht('Invalid');
                 } else {
                     $xactions[] = id(new PhabricatorMacroTransaction())->setTransactionType(PhabricatorMacroTransaction::TYPE_AUDIO)->setNewValue($file->getPHID());
                 }
             } else {
                 $errors[] = pht('You must upload an audio file.');
                 $e_file = pht('Required');
             }
         }
         if (!$errors) {
             id(new PhabricatorMacroEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->applyTransactions($macro, $xactions);
             return id(new AphrontRedirectResponse())->setURI($view_uri);
         }
     }
     $form = id(new AphrontFormView())->addHiddenInput('behaviorForm', 1)->setUser($viewer);
     $options = id(new AphrontFormRadioButtonControl())->setLabel(pht('Audio Behavior'))->setName('audioBehavior')->setValue(nonempty($macro->getAudioBehavior(), PhabricatorFileImageMacro::AUDIO_BEHAVIOR_NONE));
     $options->addButton(PhabricatorFileImageMacro::AUDIO_BEHAVIOR_NONE, pht('Do Not Play'), pht('Do not play audio.'));
     $options->addButton(PhabricatorFileImageMacro::AUDIO_BEHAVIOR_ONCE, pht('Play Once'), pht('Play audio once, when the viewer looks at the macro.'));
     $options->addButton(PhabricatorFileImageMacro::AUDIO_BEHAVIOR_LOOP, pht('Play Continuously'), pht('Play audio continuously, treating the macro as an audio source. ' . 'Best for ambient sounds.'));
     $form->appendChild($options);
     $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Audio Behavior'))->addCancelButton($view_uri));
     $crumbs = $this->buildApplicationCrumbs();
     $title = pht('Edit Audio: %s', $macro->getName());
     $crumb = pht('Edit Audio');
     $crumbs->addTextCrumb(pht('Macro "%s"', $macro->getName()), $view_uri);
     $crumbs->addTextCrumb($crumb, $request->getRequestURI());
     $crumbs->setBorder(true);
     $upload_form = id(new AphrontFormView())->setEncType('multipart/form-data')->setUser($viewer)->appendChild(id(new AphrontFormFileControl())->setLabel(pht('Audio File'))->setName('file'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload File')));
     $upload = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Audio'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Behavior'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-pencil');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $upload));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:59,代码来源:PhabricatorMacroAudioController.php

示例4: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $blog = id(new PhameBlogQuery())->setViewer($viewer)->withIDs(array($id))->needHeaderImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$blog) {
         return new Aphront404Response();
     }
     $blog_uri = '/phame/blog/manage/' . $id;
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     $delete_header = $request->getInt('delete') == 1;
     if ($request->isFormPost()) {
         if ($request->getFileExists('header')) {
             $file = PhabricatorFile::newFromPHPUpload($_FILES['header'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
         } else {
             if (!$delete_header) {
                 $e_file = pht('Required');
                 $errors[] = pht('You must choose a file when uploading a new blog header.');
             }
         }
         if (!$errors && !$delete_header) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             }
         }
         if (!$errors) {
             if ($delete_header) {
                 $new_value = null;
             } else {
                 $file->attachToObject($blog->getPHID());
                 $new_value = $file->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new PhameBlogTransaction())->setTransactionType(PhameBlogTransaction::TYPE_HEADERIMAGE)->setNewValue($new_value);
             $editor = id(new PhameBlogEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($blog, $xactions);
             return id(new AphrontRedirectResponse())->setURI($blog_uri);
         }
     }
     $title = pht('Edit Blog Header');
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('header')->setLabel(pht('Upload Header'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormCheckboxControl())->setName('delete')->setLabel(pht('Delete Header'))->addCheckbox('delete', 1, null, null))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($blog_uri)->setValue(pht('Upload Header')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Header'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Blogs'), $this->getApplicationURI('blog/'));
     $crumbs->addTextCrumb($blog->getName(), $this->getApplicationURI('blog/view/' . $id));
     $crumbs->addTextCrumb(pht('Blog Header'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Blog Header'))->setHeaderIcon('fa-camera');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($upload_box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($view));
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:54,代码来源:PhameBlogHeaderPictureController.php

示例5: getParameterValue

 protected function getParameterValue(AphrontRequest $request, $key)
 {
     $value = $request->getStrList($key);
     if ($value) {
         return head($value);
     }
     // NOTE: At least for now, we'll attempt to read a direct upload if we
     // miss on a PHID. Currently, PHUIFormFileControl does a client-side
     // upload on workflow forms (which is good) but doesn't have a hook for
     // non-workflow forms (which isn't as good). Giving it a hook is desirable,
     // but complicated. Even if we do hook it, it may be reasonable to keep
     // this code around as a fallback if the client-side JS goes awry.
     $file_key = $this->getFileKey($key);
     if (!$request->getFileExists($file_key)) {
         return null;
     }
     $viewer = $this->getViewer();
     $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, $file_key), array('authorPHID' => $viewer->getPHID(), 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
     return $file->getPHID();
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:20,代码来源:AphrontFileHTTPParameterType.php

示例6: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $this->setUser($user);
     $done_uri = $this->getApplicationURI("manage/{$id}/");
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new profile picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $user->setProfileImagePHID(null);
             } else {
                 $user->setProfileImagePHID($xformed->getPHID());
                 $xformed->attachToObject($user->getPHID());
             }
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($done_uri);
         }
     }
     $title = pht('Edit Profile Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
     $images = array();
     $current = $user->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $builtins = array('user1.png', 'user2.png', 'user3.png', 'user4.png', 'user5.png', 'user6.png', 'user7.png', 'user8.png', 'user9.png');
     foreach ($builtins as $builtin) {
         $file = PhabricatorFile::loadBuiltin($viewer, $builtin);
         $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => pht('Builtin Image'));
     }
     // Try to add external account images for any associated external accounts.
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($user->getPHID()))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     foreach ($accounts as $account) {
         $file = $account->getProfileImageFile();
         if ($account->getProfileImagePHID() != $file->getPHID()) {
             // This is a default image, just skip it.
             continue;
         }
         $provider = PhabricatorAuthProvider::getEnabledProviderByKey($account->getProviderKey());
         if ($provider) {
             $tip = pht('Picture From %s', $provider->getProviderName());
         } else {
             $tip = pht('Picture From External Account');
         }
         if ($file->isTransformableImage()) {
             $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => $tip);
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
//.........这里部分代码省略.........
开发者ID:chirag-goel,项目名称:phabricator,代码行数:101,代码来源:PhabricatorPeopleProfilePictureController.php

示例7: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $conpherence = id(new ConpherenceThreadQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$conpherence) {
         return new Aphront404Response();
     }
     $monogram = $conpherence->getMonogram();
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new room picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $xformed->attachToObject($conpherence->getPHID());
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($new_value);
             $editor = id(new ConpherenceEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($conpherence, $xactions);
             return id(new AphrontRedirectResponse())->setURI('/' . $monogram);
         }
     }
     $title = pht('Edit Room Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
     $images = array();
     $current = $conpherence->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->executeOne();
         if ($file) {
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/' . $monogram)->setValue(pht('Upload Picture')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($conpherence->getTitle(), '/' . $monogram);
     $crumbs->addTextCrumb(pht('Room Picture'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Room Picture'))->setHeaderIcon('fa-camera');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $upload_box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($view));
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:93,代码来源:ConpherenceRoomPictureController.php

示例8: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     // If we're on the "Update Diff" workflow, load the revision we're going
     // to update.
     $revision = null;
     $revision_id = $request->getURIData('revisionID');
     if ($revision_id) {
         $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($revision_id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$revision) {
             return new Aphront404Response();
         }
     }
     $diff = null;
     // This object is just for policy stuff
     $diff_object = DifferentialDiff::initializeNewDiff($viewer);
     $repository_phid = null;
     $errors = array();
     $e_diff = null;
     $e_file = null;
     $validation_exception = null;
     if ($request->isFormPost()) {
         $repository_tokenizer = $request->getArr(id(new DifferentialRepositoryField())->getFieldKey());
         if ($repository_tokenizer) {
             $repository_phid = reset($repository_tokenizer);
         }
         if ($request->getFileExists('diff-file')) {
             $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
         } else {
             $diff = $request->getStr('diff');
         }
         if (!strlen($diff)) {
             $errors[] = pht('You can not create an empty diff. Paste a diff or upload a ' . 'file containing a diff.');
             $e_diff = pht('Required');
             $e_file = pht('Required');
         }
         if (!$errors) {
             try {
                 $call = new ConduitCall('differential.createrawdiff', array('diff' => $diff, 'repositoryPHID' => $repository_phid, 'viewPolicy' => $request->getStr('viewPolicy')));
                 $call->setUser($viewer);
                 $result = $call->execute();
                 $diff_id = $result['id'];
                 $uri = $this->getApplicationURI("diff/{$diff_id}/");
                 $uri = new PhutilURI($uri);
                 if ($revision) {
                     $uri->setQueryParam('revisionID', $revision->getID());
                 }
                 return id(new AphrontRedirectResponse())->setURI($uri);
             } catch (PhabricatorApplicationTransactionValidationException $ex) {
                 $validation_exception = $ex;
             }
         }
     }
     $form = new AphrontFormView();
     $arcanist_href = PhabricatorEnv::getDoclink('Arcanist User Guide');
     $arcanist_link = phutil_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), pht('Learn More'));
     $cancel_uri = $this->getApplicationURI();
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($diff_object)->execute();
     $info_view = null;
     if (!$request->isFormPost()) {
         $info_view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setErrors(array(array(pht('The best way to create a diff is to use the Arcanist ' . 'command-line tool.'), ' ', $arcanist_link), pht('You can also paste a diff below, or upload a file ' . 'containing a diff (for example, from %s, %s or %s).', phutil_tag('tt', array(), 'svn diff'), phutil_tag('tt', array(), 'git diff'), phutil_tag('tt', array(), 'hg diff --git'))));
     }
     if ($revision) {
         $title = pht('Update Diff');
         $header = pht('Update Diff');
         $button = pht('Continue');
     } else {
         $title = pht('Create Diff');
         $header = pht('Create New Diff');
         $button = pht('Create Diff');
     }
     $form->setEncType('multipart/form-data')->setUser($viewer);
     if ($revision) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Updating Revision'))->setValue($viewer->renderHandle($revision->getPHID())));
     }
     if ($repository_phid) {
         $repository_value = array($repository_phid);
     } else {
         $repository_value = array();
     }
     $form->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Raw Diff'))->setName('diff')->setValue($diff)->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setError($e_diff))->appendChild(id(new AphrontFormFileControl())->setLabel(pht('Raw Diff From File'))->setName('diff-file')->setError($e_file))->appendControl(id(new AphrontFormTokenizerControl())->setName(id(new DifferentialRepositoryField())->getFieldKey())->setLabel(pht('Repository'))->setDatasource(new DiffusionRepositoryDatasource())->setValue($repository_value)->setLimit(1))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setName('viewPolicy')->setPolicyObject($diff_object)->setPolicies($policies)->setCapability(PhabricatorPolicyCapability::CAN_VIEW))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($button));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($header)->setValidationException($validation_exception)->setForm($form)->setFormErrors($errors);
     if ($info_view) {
         $form_box->setInfoView($info_view);
     }
     $crumbs = $this->buildApplicationCrumbs();
     if ($revision) {
         $crumbs->addTextCrumb($revision->getMonogram(), '/' . $revision->getMonogram());
     }
     $crumbs->addTextCrumb($title);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:92,代码来源:DifferentialDiffCreateController.php

示例9: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($id))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getApplicationURI('profile/' . $project->getID() . '/');
     $view_uri = $this->getApplicationURI('profile/' . $project->getID() . '/');
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new project picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)->setNewValue($new_value);
             $editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($project, $xactions);
             return id(new AphrontRedirectResponse())->setURI($edit_uri);
         }
     }
     $title = pht('Edit Project Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'project.png');
     $images = array();
     $current = $project->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $launch_id = celerity_generate_unique_node_id();
     $input_id = celerity_generate_unique_node_id();
     Javelin::initBehavior('launch-icon-composer', array('launchID' => $launch_id, 'inputID' => $input_id));
     $compose_button = javelin_tag('button', array('class' => 'grey', 'id' => $launch_id, 'sigil' => 'icon-composer'), pht('Choose Icon and Color...'));
     $compose_input = javelin_tag('input', array('type' => 'hidden', 'id' => $input_id, 'name' => 'phid'));
     $compose_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($compose_input, $compose_button));
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Quick Create'))->setValue($compose_form));
     $default_button = javelin_tag('button', array('class' => 'grey'), pht('Use Project Icon'));
     $default_input = javelin_tag('input', array('type' => 'hidden', 'name' => 'projectPHID', 'value' => $project->getPHID()));
     $default_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST', 'action' => '/file/compose/'), array($default_input, $default_button));
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Default'))->setValue($default_form));
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($edit_uri)->setValue(pht('Upload Picture')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
     $nav = $this->buildIconNavView($project);
     $nav->selectFilter("edit/{$id}/");
     $nav->appendChild($form_box);
//.........这里部分代码省略.........
开发者ID:patelhardik,项目名称:phabricator,代码行数:101,代码来源:PhabricatorProjectEditPictureController.php

示例10: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $this->requireApplicationCapability(PhabricatorMacroManageCapability::CAPABILITY);
     if ($id) {
         $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withIDs(array($id))->needFiles(true)->executeOne();
         if (!$macro) {
             return new Aphront404Response();
         }
     } else {
         $macro = new PhabricatorFileImageMacro();
         $macro->setAuthorPHID($viewer->getPHID());
     }
     $errors = array();
     $e_name = true;
     $e_file = null;
     $file = null;
     if ($request->isFormPost()) {
         $original = clone $macro;
         $new_name = null;
         if ($request->getBool('name_form') || !$macro->getID()) {
             $new_name = $request->getStr('name');
             $macro->setName($new_name);
             if (!strlen($macro->getName())) {
                 $errors[] = pht('Macro name is required.');
                 $e_name = pht('Required');
             } else {
                 if (!preg_match('/^[a-z0-9:_-]{3,}\\z/', $macro->getName())) {
                     $errors[] = pht('Macro must be at least three characters long and contain only ' . 'lowercase letters, digits, hyphens, colons and underscores.');
                     $e_name = pht('Invalid');
                 } else {
                     $e_name = null;
                 }
             }
         }
         $uri = $request->getStr('url');
         $engine = new PhabricatorDestructionEngine();
         $file = null;
         if ($request->getFileExists('file')) {
             $file = PhabricatorFile::newFromPHPUpload($_FILES['file'], array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'isExplicitUpload' => true, 'canCDN' => true));
         } else {
             if ($uri) {
                 try {
                     // Rate limit outbound fetches to make this mechanism less useful for
                     // scanning networks and ports.
                     PhabricatorSystemActionEngine::willTakeAction(array($viewer->getPHID()), new PhabricatorFilesOutboundRequestAction(), 1);
                     $file = PhabricatorFile::newFromFileDownload($uri, array('name' => $request->getStr('name'), 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'isExplicitUpload' => true, 'canCDN' => true));
                     if (!$file->isViewableInBrowser()) {
                         $mime_type = $file->getMimeType();
                         $engine->destroyObject($file);
                         $file = null;
                         throw new Exception(pht('The URI "%s" does not correspond to a valid image file, got ' . 'a file with MIME type "%s". You must specify the URI of a ' . 'valid image file.', $uri, $mime_type));
                     } else {
                         $file->setAuthorPHID($viewer->getPHID())->save();
                     }
                 } catch (HTTPFutureHTTPResponseStatus $status) {
                     $errors[] = pht('The URI "%s" could not be loaded, got %s error.', $uri, $status->getStatusCode());
                 } catch (Exception $ex) {
                     $errors[] = $ex->getMessage();
                 }
             } else {
                 if ($request->getStr('phid')) {
                     $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($request->getStr('phid')))->executeOne();
                 }
             }
         }
         if ($file) {
             if (!$file->isViewableInBrowser()) {
                 $errors[] = pht('You must upload an image.');
                 $e_file = pht('Invalid');
             } else {
                 $macro->setFilePHID($file->getPHID());
                 $macro->attachFile($file);
                 $e_file = null;
             }
         }
         if (!$macro->getID() && !$file) {
             $errors[] = pht('You must upload an image to create a macro.');
             $e_file = pht('Required');
         }
         if (!$errors) {
             try {
                 $xactions = array();
                 if ($new_name !== null) {
                     $xactions[] = id(new PhabricatorMacroTransaction())->setTransactionType(PhabricatorMacroTransaction::TYPE_NAME)->setNewValue($new_name);
                 }
                 if ($file) {
                     $xactions[] = id(new PhabricatorMacroTransaction())->setTransactionType(PhabricatorMacroTransaction::TYPE_FILE)->setNewValue($file->getPHID());
                 }
                 $editor = id(new PhabricatorMacroEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
                 $xactions = $editor->applyTransactions($original, $xactions);
                 $view_uri = $this->getApplicationURI('/view/' . $original->getID() . '/');
                 return id(new AphrontRedirectResponse())->setURI($view_uri);
             } catch (AphrontDuplicateKeyQueryException $ex) {
                 throw $ex;
                 $errors[] = pht('Macro name is not unique!');
                 $e_name = pht('Duplicate');
             }
         }
//.........这里部分代码省略.........
开发者ID:pugong,项目名称:phabricator,代码行数:101,代码来源:PhabricatorMacroEditController.php


注:本文中的AphrontRequest::getFileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。