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


PHP AphrontRequest::getArr方法代码示例

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


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

示例1: buildSavedQueryFromRequest

 public function buildSavedQueryFromRequest(AphrontRequest $request)
 {
     $saved = new PhabricatorSavedQuery();
     $saved->setParameter('status', $request->getArr('status'));
     $saved->setParameter('order', $request->getArr('order'));
     return $saved;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:PhrictionSearchEngine.php

示例2: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needPaths(true)->executeOne();
     if (!$package) {
         return new Aphront404Response();
     }
     if ($request->isFormPost()) {
         $paths = $request->getArr('path');
         $repos = $request->getArr('repo');
         $excludes = $request->getArr('exclude');
         $path_refs = array();
         foreach ($paths as $key => $path) {
             if (!isset($repos[$key])) {
                 throw new Exception(pht('No repository PHID for path "%s"!', $key));
             }
             if (!isset($excludes[$key])) {
                 throw new Exception(pht('No exclusion value for path "%s"!', $key));
             }
             $path_refs[] = array('repositoryPHID' => $repos[$key], 'path' => $path, 'excluded' => (int) $excludes[$key]);
         }
         $type_paths = PhabricatorOwnersPackageTransaction::TYPE_PATHS;
         $xactions = array();
         $xactions[] = id(new PhabricatorOwnersPackageTransaction())->setTransactionType($type_paths)->setNewValue($path_refs);
         $editor = id(new PhabricatorOwnersPackageTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
         $editor->applyTransactions($package, $xactions);
         return id(new AphrontRedirectResponse())->setURI($package->getURI());
     } else {
         $paths = $package->getPaths();
         $path_refs = mpull($paths, 'getRef');
     }
     $repos = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->execute();
     $default_paths = array();
     foreach ($repos as $repo) {
         $default_path = $repo->getDetail('default-owners-path');
         if ($default_path) {
             $default_paths[$repo->getPHID()] = $default_path;
         }
     }
     $repos = mpull($repos, 'getDisplayName', 'getPHID');
     asort($repos);
     $template = new AphrontTypeaheadTemplateView();
     $template = $template->render();
     Javelin::initBehavior('owners-path-editor', array('root' => 'path-editor', 'table' => 'paths', 'add_button' => 'addpath', 'repositories' => $repos, 'input_template' => $template, 'pathRefs' => $path_refs, 'completeURI' => '/diffusion/services/path/complete/', 'validateURI' => '/diffusion/services/path/validate/', 'repositoryDefaultPaths' => $default_paths));
     require_celerity_resource('owners-path-editor-css');
     $cancel_uri = $package->getURI();
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new PHUIFormInsetView())->setTitle(pht('Paths'))->addDivAttributes(array('id' => 'path-editor'))->setRightButton(javelin_tag('a', array('href' => '#', 'class' => 'button green', 'sigil' => 'addpath', 'mustcapture' => true), pht('Add New Path')))->setDescription(pht('Specify the files and directories which comprise ' . 'this package.'))->setContent(javelin_tag('table', array('class' => 'owners-path-editor-table', 'sigil' => 'paths'), '')))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue(pht('Save Paths')));
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Paths'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($package->getName(), $this->getApplicationURI('package/' . $package->getID() . '/'));
     $crumbs->addTextCrumb(pht('Edit Paths'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Paths: %s', $package->getName()))->setHeaderIcon('fa-pencil');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($box);
     $title = array($package->getName(), pht('Edit Paths'));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:57,代码来源:PhabricatorOwnersPathsController.php

示例3: buildSavedQueryFromRequest

 public function buildSavedQueryFromRequest(AphrontRequest $request)
 {
     $saved = new PhabricatorSavedQuery();
     $saved->setParameter('callsigns', $request->getStrList('callsigns'));
     $saved->setParameter('status', $request->getStr('status'));
     $saved->setParameter('order', $request->getStr('order'));
     $saved->setParameter('hosted', $request->getStr('hosted'));
     $saved->setParameter('types', $request->getArr('types'));
     $saved->setParameter('name', $request->getStr('name'));
     $saved->setParameter('anyProjectPHIDs', $request->getArr('anyProjects'));
     return $saved;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:12,代码来源:PhabricatorRepositorySearchEngine.php

示例4: readValueFromRequest

 public function readValueFromRequest(AphrontRequest $request)
 {
     $value = array();
     $names = $request->getArr($this->getFieldKey() . '_name');
     $panels = $request->getArr($this->getFieldKey() . '_panelID');
     foreach ($names as $idx => $name) {
         $panel_id = idx($panels, $idx);
         if (strlen($name) && $panel_id) {
             $value[] = array('name' => $name, 'panelID' => $panel_id);
         }
     }
     $this->setFieldValue($value);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhabricatorDashboardPanelTabsCustomField.php

示例5: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $engine = id(new PhabricatorProjectEditEngine())->setController($this);
     $this->setEngine($engine);
     $id = $request->getURIData('id');
     if (!$id) {
         // This capability is checked again later, but checking it here
         // explicitly gives us a better error message.
         $this->requireApplicationCapability(ProjectCreateProjectsCapability::CAPABILITY);
         $parent_id = head($request->getArr('parent'));
         if (!$parent_id) {
             $parent_id = $request->getStr('parent');
         }
         if ($parent_id) {
             $is_milestone = false;
         } else {
             $parent_id = head($request->getArr('milestone'));
             if (!$parent_id) {
                 $parent_id = $request->getStr('milestone');
             }
             $is_milestone = true;
         }
         if ($parent_id) {
             $query = id(new PhabricatorProjectQuery())->setViewer($viewer)->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT));
             if (ctype_digit($parent_id)) {
                 $query->withIDs(array($parent_id));
             } else {
                 $query->withPHIDs(array($parent_id));
             }
             $parent = $query->executeOne();
             if ($is_milestone) {
                 if (!$parent->supportsMilestones()) {
                     $cancel_uri = "/project/subprojects/{$parent_id}/";
                     return $this->newDialog()->setTitle(pht('No Milestones'))->appendParagraph(pht('You can not add milestones to this project.'))->addCancelButton($cancel_uri);
                 }
                 $engine->setMilestoneProject($parent);
             } else {
                 if (!$parent->supportsSubprojects()) {
                     $cancel_uri = "/project/subprojects/{$parent_id}/";
                     return $this->newDialog()->setTitle(pht('No Subprojects'))->appendParagraph(pht('You can not add subprojects to this project.'))->addCancelButton($cancel_uri);
                 }
                 $engine->setParentProject($parent);
             }
             $this->setProject($parent);
         }
     }
     return $engine->buildResponse();
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:49,代码来源:PhabricatorProjectEditController.php

示例6: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $project_id = $request->getURIData('projectID');
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($project_id))->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $this->setProject($project);
     $columns = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withProjectPHIDs(array($project->getPHID()))->execute();
     if ($columns) {
         return new Aphront400Response();
     }
     $project_id = $project->getID();
     $board_uri = $this->getApplicationURI("board/{$project_id}/");
     if ($request->isFormPost()) {
         $import_phid = $request->getArr('importProjectPHID');
         $import_phid = reset($import_phid);
         $import_columns = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withProjectPHIDs(array($import_phid))->execute();
         if (!$import_columns) {
             return new Aphront400Response();
         }
         $table = id(new PhabricatorProjectColumn())->openTransaction();
         foreach ($import_columns as $import_column) {
             if ($import_column->isHidden()) {
                 continue;
             }
             $new_column = PhabricatorProjectColumn::initializeNewColumn($viewer)->setSequence($import_column->getSequence())->setProjectPHID($project->getPHID())->setName($import_column->getName())->setProperties($import_column->getProperties())->save();
         }
         $table->saveTransaction();
         return id(new AphrontRedirectResponse())->setURI($board_uri);
     }
     $proj_selector = id(new AphrontFormTokenizerControl())->setName('importProjectPHID')->setUser($viewer)->setDatasource(id(new PhabricatorProjectDatasource())->setParameters(array('mustHaveColumns' => true))->setLimit(1));
     return $this->newDialog()->setTitle(pht('Import Columns'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendParagraph(pht('Choose a project to import columns from:'))->appendChild($proj_selector)->addCancelButton($board_uri)->addSubmitButton(pht('Import'));
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:35,代码来源:PhabricatorProjectBoardImportController.php

示例7: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $response = $this->loadDiffusionContextForEdit();
     if ($response) {
         return $response;
     }
     $viewer = $this->getViewer();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     if (!$repository->supportsAutomation()) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
     $v_blueprints = $repository->getHumanReadableDetail('automation.blueprintPHIDs');
     if ($request->isFormPost()) {
         $v_blueprints = $request->getArr('blueprintPHIDs');
         $xactions = array();
         $template = id(new PhabricatorRepositoryTransaction());
         $type_blueprints = PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS;
         $xactions[] = id(clone $template)->setTransactionType($type_blueprints)->setNewValue($v_blueprints);
         id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($repository, $xactions);
         return id(new AphrontRedirectResponse())->setURI($edit_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Automation'));
     $title = pht('Edit %s', $repository->getName());
     $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht("Configure **Repository Automation** to allow Phabricator to " . "write to this repository." . "\n\n" . "IMPORTANT: This feature is new, experimental, and not supported. " . "Use it at your own risk."))->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Use Blueprints'))->setName('blueprintPHIDs')->setValue($v_blueprints)->setDatasource(new DrydockBlueprintDatasource()))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($edit_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($object_box);
 }
开发者ID:truSense,项目名称:phabricator,代码行数:30,代码来源:DiffusionRepositoryEditAutomationController.php

示例8: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getViewer();
     $id = $request->getURIData('id');
     if ($id) {
         $question = id(new PonderQuestionQuery())->setViewer($user)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$question) {
             return new Aphront404Response();
         }
         $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs($question->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
         $v_projects = array_reverse($v_projects);
     } else {
         $question = id(new PonderQuestion())->setStatus(PonderQuestionStatus::STATUS_OPEN)->setAuthorPHID($user->getPHID())->setVoteCount(0)->setAnswerCount(0)->setHeat(0.0);
         $v_projects = array();
     }
     $v_title = $question->getTitle();
     $v_content = $question->getContent();
     $errors = array();
     $e_title = true;
     if ($request->isFormPost()) {
         $v_title = $request->getStr('title');
         $v_content = $request->getStr('content');
         $v_projects = $request->getArr('projects');
         $len = phutil_utf8_strlen($v_title);
         if ($len < 1) {
             $errors[] = pht('Title must not be empty.');
             $e_title = pht('Required');
         } else {
             if ($len > 255) {
                 $errors[] = pht('Title is too long.');
                 $e_title = pht('Too Long');
             }
         }
         if (!$errors) {
             $template = id(new PonderQuestionTransaction());
             $xactions = array();
             $xactions[] = id(clone $template)->setTransactionType(PonderQuestionTransaction::TYPE_TITLE)->setNewValue($v_title);
             $xactions[] = id(clone $template)->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)->setNewValue($v_content);
             $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
             $xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $proj_edge_type)->setNewValue(array('=' => array_fuse($v_projects)));
             $editor = id(new PonderQuestionEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
             $editor->applyTransactions($question, $xactions);
             return id(new AphrontRedirectResponse())->setURI('/Q' . $question->getID());
         }
     }
     $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Question'))->setName('title')->setValue($v_title)->setError($e_title))->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('content')->setID('content')->setValue($v_content)->setLabel(pht('Description'))->setUser($user));
     $form->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Projects'))->setName('projects')->setValue($v_projects)->setDatasource(new PhabricatorProjectDatasource()));
     $form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getApplicationURI())->setValue(pht('Ask Away!')));
     $preview = id(new PHUIRemarkupPreviewPanel())->setHeader(pht('Question Preview'))->setControlID('content')->setPreviewURI($this->getApplicationURI('preview/'));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Ask New Question'))->setFormErrors($errors)->setForm($form);
     $crumbs = $this->buildApplicationCrumbs();
     $id = $question->getID();
     if ($id) {
         $crumbs->addTextCrumb("Q{$id}", "/Q{$id}");
         $crumbs->addTextCrumb(pht('Edit'));
     } else {
         $crumbs->addTextCrumb(pht('Ask Question'));
     }
     return $this->buildApplicationPage(array($crumbs, $form_box, $preview), array('title' => pht('Ask New Question')));
 }
开发者ID:xlz926,项目名称:phabricator,代码行数:60,代码来源:PonderQuestionEditController.php

示例9: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $this->viewer = $request->getViewer();
     if ($request->isFormPost()) {
         $uri = $request->getRequestURI();
         $project = head($request->getArr('set_project'));
         $project = nonempty($project, null);
         $uri = $uri->alter('project', $project);
         $window = $request->getStr('set_window');
         $uri = $uri->alter('window', $window);
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $error_box = null;
     $history_model = id(new SprintHistoryDataProvider())->setViewer($this->viewer)->setRequest($request)->execute();
     try {
         $sprintlist_table = id(new SprintHistoryTableView())->setViewer($this->viewer)->setRequest($request)->setTableData($history_model)->render();
     } catch (Exception $e) {
         $error_box = $this->getErrorBox($e);
     }
     $can_create = $this->hasApplicationCapability(ProjectCreateProjectsCapability::CAPABILITY);
     $crumbs = $this->buildSprintApplicationCrumbs($can_create);
     $crumbs->addTextCrumb(pht('Task Project History'));
     $help = id(new PHUIBoxView())->appendChild(phutil_tag('p', array(), 'This is a history of tasks and logs when a project was added or removed'))->appendChild(phutil_tag('br', array(), ''))->appendChild(phutil_tag('p', array(), 'NOTE: The tasks are selected from the current tasks in the project.  Tasks previously removed
         will not appear!'))->addMargin(PHUI::MARGIN_LARGE);
     $nav = $this->buildNavMenu();
     $this->view = $nav->selectFilter($this->view, 'history');
     $nav->appendChild(array($error_box, $crumbs, $help, $sprintlist_table));
     return $this->buildApplicationPage($nav, array('title' => array(pht('Task Project History')), 'device' => true));
 }
开发者ID:yangming85,项目名称:phabricator-extensions-Sprint,代码行数:29,代码来源:SprintHistoryController.php

示例10: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $phids = $request->getArr('phids');
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     $objects = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     $cards = array();
     foreach ($phids as $phid) {
         $handle = $handles[$phid];
         $object = $objects[$phid];
         $hovercard = id(new PhabricatorHovercardView())->setUser($viewer)->setObjectHandle($handle);
         if ($object) {
             $hovercard->setObject($object);
         }
         // Send it to the other side of the world, thanks to PhutilEventEngine
         $event = new PhabricatorEvent(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD, array('hovercard' => $hovercard, 'handle' => $handle, 'object' => $object));
         $event->setUser($viewer);
         PhutilEventEngine::dispatchEvent($event);
         $cards[$phid] = $hovercard;
     }
     // Browser-friendly for non-Ajax requests
     if (!$request->isAjax()) {
         foreach ($cards as $key => $hovercard) {
             $cards[$key] = phutil_tag('div', array('class' => 'ml'), $hovercard);
         }
         return $this->buildApplicationPage($cards, array('device' => false));
     } else {
         return id(new AphrontAjaxResponse())->setContent(array('cards' => $cards));
     }
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:30,代码来源:PhabricatorSearchHovercardController.php

示例11: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $phid = head($request->getArr('macro'));
     $above = $request->getStr('above');
     $below = $request->getStr('below');
     $e_macro = true;
     $errors = array();
     if ($request->isDialogFormPost()) {
         if (!$phid) {
             $e_macro = pht('Required');
             $errors[] = pht('Macro name is required.');
         } else {
             $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             if (!$macro) {
                 $e_macro = pht('Invalid');
                 $errors[] = pht('No such macro.');
             }
         }
         if (!$errors) {
             $options = new PhutilSimpleOptions();
             $data = array('src' => $macro->getName(), 'above' => $above, 'below' => $below);
             $string = $options->unparse($data, $escape = '}');
             $result = array('text' => "{meme, {$string}}");
             return id(new AphrontAjaxResponse())->setContent($result);
         }
     }
     $view = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Macro'))->setName('macro')->setLimit(1)->setDatasource(new PhabricatorMacroDatasource())->setError($e_macro))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Above'))->setName('above')->setValue($above))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Below'))->setName('below')->setValue($below));
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Create Meme'))->appendForm($view)->addCancelButton('/')->addSubmitButton(pht('Llama Diorama'));
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMacroMemeDialogController.php

示例12: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     if ($id) {
         $account = id(new PhortuneAccountQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$account) {
             return new Aphront404Response();
         }
         $is_new = false;
     } else {
         $account = PhortuneAccount::initializeNewAccount($viewer);
         $account->attachMemberPHIDs(array($viewer->getPHID()));
         $is_new = true;
     }
     $v_name = $account->getName();
     $e_name = true;
     $v_members = $account->getMemberPHIDs();
     $e_members = null;
     $validation_exception = null;
     if ($request->isFormPost()) {
         $v_name = $request->getStr('name');
         $v_members = $request->getArr('memberPHIDs');
         $type_name = PhortuneAccountTransaction::TYPE_NAME;
         $type_edge = PhabricatorTransactions::TYPE_EDGE;
         $xactions = array();
         $xactions[] = id(new PhortuneAccountTransaction())->setTransactionType($type_name)->setNewValue($v_name);
         $xactions[] = id(new PhortuneAccountTransaction())->setTransactionType($type_edge)->setMetadataValue('edge:type', PhortuneAccountHasMemberEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($v_members)));
         $editor = id(new PhortuneAccountEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($account, $xactions);
             $account_uri = $this->getApplicationURI($account->getID() . '/');
             return id(new AphrontRedirectResponse())->setURI($account_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
             $e_name = $ex->getShortMessage($type_name);
             $e_members = $ex->getShortMessage($type_edge);
         }
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     if ($is_new) {
         $cancel_uri = $this->getApplicationURI('account/');
         $crumbs->addTextCrumb(pht('Accounts'), $cancel_uri);
         $crumbs->addTextCrumb(pht('Create Account'));
         $title = pht('Create Payment Account');
         $submit_button = pht('Create Account');
     } else {
         $cancel_uri = $this->getApplicationURI($account->getID() . '/');
         $crumbs->addTextCrumb($account->getName(), $cancel_uri);
         $crumbs->addTextCrumb(pht('Edit'));
         $title = pht('Edit %s', $account->getName());
         $submit_button = pht('Save Changes');
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel(pht('Name'))->setValue($v_name)->setError($e_name))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setLabel(pht('Members'))->setName('memberPHIDs')->setValue($v_members)->setError($e_members))->appendChild(id(new AphrontFormSubmitControl())->setValue($submit_button)->addCancelButton($cancel_uri));
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Account'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setValidationException($validation_exception)->setForm($form);
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-pencil');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:60,代码来源:PhortuneAccountEditController.php

示例13: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needProjectPHIDs(true)->withNames(array($book_name))->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $view_uri = '/book/' . $book->getName() . '/';
     if ($request->isFormPost()) {
         $v_projects = $request->getArr('projectPHIDs');
         $v_view = $request->getStr('viewPolicy');
         $v_edit = $request->getStr('editPolicy');
         $xactions = array();
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($v_projects)));
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
         id(new DivinerLiveBookEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($book, $xactions);
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Basics'));
     $title = pht('Edit %s', $book->getTitle());
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($book)->execute();
     $view_capability = PhabricatorPolicyCapability::CAN_VIEW;
     $edit_capability = PhabricatorPolicyCapability::CAN_EDIT;
     $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Projects'))->setValue($book->getProjectPHIDs()))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionRepositoryDatasource())->setName('repositoryPHIDs')->setLabel(pht('Repository'))->setDisableBehavior(true)->setLimit(1)->setValue($book->getRepositoryPHID() ? array($book->getRepositoryPHID()) : null))->appendChild(id(new AphrontFormPolicyControl())->setName('viewPolicy')->setPolicyObject($book)->setCapability($view_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($view_capability)))->appendChild(id(new AphrontFormPolicyControl())->setName('editPolicy')->setPolicyObject($book)->setCapability($edit_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($edit_capability)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($view_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     $timeline = $this->buildTransactionTimeline($book, new DivinerLiveBookTransactionQuery());
     $timeline->setShouldTerminate(true);
     return $this->buildApplicationPage(array($crumbs, $object_box, $timeline), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:32,代码来源:DivinerBookEditController.php

示例14: handleRequest

    public function handleRequest(AphrontRequest $request)
    {
        $engine_key = $request->getURIData('engineKey');
        $this->setEngineKey($engine_key);
        $key = $request->getURIData('key');
        $viewer = $this->getViewer();
        $config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
        if (!$config) {
            return id(new Aphront404Response());
        }
        $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
        if ($request->isFormPost()) {
            $xactions = array();
            $locks = $request->getArr('locks');
            $type_locks = PhabricatorEditEngineConfigurationTransaction::TYPE_LOCKS;
            $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type_locks)->setNewValue($locks);
            $editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
            $editor->applyTransactions($config, $xactions);
            return id(new AphrontRedirectResponse())->setURI($cancel_uri);
        }
        $engine = $config->getEngine();
        $fields = $engine->getFieldsForConfig($config);
        $help = pht(<<<EOTEXT
**Locked** fields are visible in the form, but their values can not be changed
by the user.

**Hidden** fields are not visible in the form.

Any assigned default values are still respected, even if the field is locked
or hidden.
EOTEXT
);
        $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions($help);
        $locks = $config->getFieldLocks();
        $lock_visible = PhabricatorEditEngineConfiguration::LOCK_VISIBLE;
        $lock_locked = PhabricatorEditEngineConfiguration::LOCK_LOCKED;
        $lock_hidden = PhabricatorEditEngineConfiguration::LOCK_HIDDEN;
        $map = array($lock_visible => pht('Visible'), $lock_locked => pht("🔒 Locked"), $lock_hidden => pht("✘ Hidden"));
        foreach ($fields as $field) {
            if (!$field->getIsLockable()) {
                continue;
            }
            $key = $field->getKey();
            $label = $field->getLabel();
            if (!strlen($label)) {
                $label = $key;
            }
            if ($field->getIsHidden()) {
                $value = $lock_hidden;
            } else {
                if ($field->getIsLocked()) {
                    $value = $lock_locked;
                } else {
                    $value = $lock_visible;
                }
            }
            $form->appendControl(id(new AphrontFormSelectControl())->setName('locks[' . $key . ']')->setLabel($label)->setValue($value)->setOptions($map));
        }
        return $this->newDialog()->setTitle(pht('Lock / Hide Fields'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendForm($form)->addSubmitButton(pht('Save Changes'))->addCancelButton($cancel_uri);
    }
开发者ID:pugong,项目名称:phabricator,代码行数:60,代码来源:PhabricatorEditEngineConfigurationLockController.php

示例15: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     if ($id) {
         $binding = id(new AlmanacBindingQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$binding) {
             return new Aphront404Response();
         }
         $service = $binding->getService();
         $is_new = false;
         $service_uri = $service->getURI();
         $cancel_uri = $binding->getURI();
         $title = pht('Edit Binding');
         $save_button = pht('Save Changes');
     } else {
         $service = id(new AlmanacServiceQuery())->setViewer($viewer)->withIDs(array($request->getStr('serviceID')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         $binding = AlmanacBinding::initializeNewBinding($service);
         $is_new = true;
         $service_uri = $service->getURI();
         $cancel_uri = $service_uri;
         $title = pht('Create Binding');
         $save_button = pht('Create Binding');
     }
     $v_interface = array();
     if ($binding->getInterfacePHID()) {
         $v_interface = array($binding->getInterfacePHID());
     }
     $e_interface = true;
     $validation_exception = null;
     if ($request->isFormPost()) {
         $v_interface = $request->getArr('interfacePHIDs');
         $type_interface = AlmanacBindingTransaction::TYPE_INTERFACE;
         $xactions = array();
         $xactions[] = id(new AlmanacBindingTransaction())->setTransactionType($type_interface)->setNewValue(head($v_interface));
         $editor = id(new AlmanacBindingEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
         try {
             $editor->applyTransactions($binding, $xactions);
             $binding_uri = $binding->getURI();
             return id(new AphrontRedirectResponse())->setURI($binding_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
             $e_interface = $ex->getShortMessage($type_interface);
         }
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setName('interfacePHIDs')->setLabel(pht('Interface'))->setLimit(1)->setDatasource(new AlmanacInterfaceDatasource())->setValue($v_interface)->setError($e_interface))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($save_button));
     $box = id(new PHUIObjectBoxView())->setValidationException($validation_exception)->setHeaderText(pht('Binding'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($service->getName(), $service_uri);
     if ($is_new) {
         $crumbs->addTextCrumb(pht('Create Binding'));
         $header = id(new PHUIHeaderView())->setHeader(pht('Create Binding'))->setHeaderIcon('fa-plus-square');
     } else {
         $crumbs->addTextCrumb(pht('Edit Binding'));
         $header = id(new PHUIHeaderView())->setHeader(pht('Create Binding'))->setHeaderIcon('fa-pencil');
     }
     $crumbs->setBorder(true);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:60,代码来源:AlmanacBindingEditController.php


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