[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhragmentUpdateController extends PhragmentController { 4 5 private $dblob; 6 7 public function willProcessRequest(array $data) { 8 $this->dblob = idx($data, 'dblob', ''); 9 } 10 11 public function processRequest() { 12 $request = $this->getRequest(); 13 $viewer = $request->getUser(); 14 15 $parents = $this->loadParentFragments($this->dblob); 16 if ($parents === null) { 17 return new Aphront404Response(); 18 } 19 $fragment = idx($parents, count($parents) - 1, null); 20 21 $error_view = null; 22 23 if ($request->isFormPost()) { 24 $errors = array(); 25 26 $v_fileid = $request->getInt('fileID'); 27 28 $file = id(new PhabricatorFile())->load($v_fileid); 29 if ($file === null) { 30 $errors[] = pht('The specified file doesn\'t exist.'); 31 } 32 33 if (!count($errors)) { 34 // If the file is a ZIP archive (has application/zip mimetype) 35 // then we extract the zip and apply versions for each of the 36 // individual fragments, creating and deleting files as needed. 37 if ($file->getMimeType() === 'application/zip') { 38 $fragment->updateFromZIP($viewer, $file); 39 } else { 40 $fragment->updateFromFile($viewer, $file); 41 } 42 43 return id(new AphrontRedirectResponse()) 44 ->setURI('/phragment/browse/'.$fragment->getPath()); 45 } else { 46 $error_view = id(new AphrontErrorView()) 47 ->setErrors($errors) 48 ->setTitle(pht('Errors while updating fragment')); 49 } 50 } 51 52 $form = id(new AphrontFormView()) 53 ->setUser($viewer) 54 ->appendChild( 55 id(new AphrontFormTextControl()) 56 ->setLabel(pht('File ID')) 57 ->setName('fileID')) 58 ->appendChild( 59 id(new AphrontFormSubmitControl()) 60 ->setValue(pht('Update Fragment')) 61 ->addCancelButton( 62 $this->getApplicationURI('browse/'.$fragment->getPath()))); 63 64 $crumbs = $this->buildApplicationCrumbsWithPath($parents); 65 $crumbs->addTextCrumb(pht('Update Fragment')); 66 67 $box = id(new PHUIObjectBoxView()) 68 ->setHeaderText(pht('Update Fragment: %s', $fragment->getPath())) 69 ->setValidationException(null) 70 ->setForm($form); 71 72 return $this->buildApplicationPage( 73 array( 74 $crumbs, 75 $this->renderConfigurationWarningIfRequired(), 76 $box, 77 ), 78 array( 79 'title' => pht('Update Fragment'), 80 )); 81 } 82 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |