本文整理汇总了PHP中AphrontRequest::getInt方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::getInt方法的具体用法?PHP AphrontRequest::getInt怎么用?PHP AphrontRequest::getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
if (!$request->validateCSRF()) {
return new Aphront403Response();
}
$task = id(new ManiphestTaskQuery())->setViewer($viewer)->withIDs(array($request->getInt('task')))->needProjectPHIDs(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$task) {
return new Aphront404Response();
}
if ($request->getInt('after')) {
$after_task = id(new ManiphestTaskQuery())->setViewer($viewer)->withIDs(array($request->getInt('after')))->executeOne();
if (!$after_task) {
return new Aphront404Response();
}
list($pri, $sub) = ManiphestTransactionEditor::getAdjacentSubpriority($after_task, $is_after = true);
} else {
list($pri, $sub) = ManiphestTransactionEditor::getEdgeSubpriority($request->getInt('priority'), $is_end = false);
}
$xactions = array();
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)->setNewValue($pri);
$xactions[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY)->setNewValue($sub);
$editor = id(new ManiphestTransactionEditor())->setActor($viewer)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
$editor->applyTransactions($task, $xactions);
return id(new AphrontAjaxResponse())->setContent(array('tasks' => $this->renderSingleTask($task)));
}
示例2: testRequestDataAccess
public function testRequestDataAccess()
{
$r = new AphrontRequest('http://example.com/', '/');
$r->setRequestData(array('str_empty' => '', 'str' => 'derp', 'str_true' => 'true', 'str_false' => 'false', 'zero' => '0', 'one' => '1', 'arr_empty' => array(), 'arr_num' => array(1, 2, 3), 'comma' => ',', 'comma_1' => 'a, b', 'comma_2' => ' ,a ,, b ,,,, ,, ', 'comma_3' => '0', 'comma_4' => 'a, a, b, a', 'comma_5' => "a\nb, c\n\nd\n\n\n,\n"));
$this->assertEqual(1, $r->getInt('one'));
$this->assertEqual(0, $r->getInt('zero'));
$this->assertEqual(null, $r->getInt('does-not-exist'));
$this->assertEqual(0, $r->getInt('str_empty'));
$this->assertEqual(true, $r->getBool('one'));
$this->assertEqual(false, $r->getBool('zero'));
$this->assertEqual(true, $r->getBool('str_true'));
$this->assertEqual(false, $r->getBool('str_false'));
$this->assertEqual(true, $r->getBool('str'));
$this->assertEqual(null, $r->getBool('does-not-exist'));
$this->assertEqual(false, $r->getBool('str_empty'));
$this->assertEqual('derp', $r->getStr('str'));
$this->assertEqual('', $r->getStr('str_empty'));
$this->assertEqual(null, $r->getStr('does-not-exist'));
$this->assertEqual(array(), $r->getArr('arr_empty'));
$this->assertEqual(array(1, 2, 3), $r->getArr('arr_num'));
$this->assertEqual(null, $r->getArr('str_empty', null));
$this->assertEqual(null, $r->getArr('str_true', null));
$this->assertEqual(null, $r->getArr('does-not-exist', null));
$this->assertEqual(array(), $r->getArr('does-not-exist'));
$this->assertEqual(array(), $r->getStrList('comma'));
$this->assertEqual(array('a', 'b'), $r->getStrList('comma_1'));
$this->assertEqual(array('a', 'b'), $r->getStrList('comma_2'));
$this->assertEqual(array('0'), $r->getStrList('comma_3'));
$this->assertEqual(array('a', 'a', 'b', 'a'), $r->getStrList('comma_4'));
$this->assertEqual(array('a', 'b', 'c', 'd'), $r->getStrList('comma_5'));
$this->assertEqual(array(), $r->getStrList('does-not-exist'));
$this->assertEqual(null, $r->getStrList('does-not-exist', null));
$this->assertEqual(true, $r->getExists('str'));
$this->assertEqual(false, $r->getExists('does-not-exist'));
}
示例3: readFormValuesFromRequest
public function readFormValuesFromRequest(AphrontRequest $request)
{
$is_setup = $this->isSetup();
if ($is_setup) {
$name = $request->getStr(self::PROPERTY_JIRA_NAME);
} else {
$name = $this->getProviderDomain();
}
return array(self::PROPERTY_JIRA_NAME => $name, self::PROPERTY_JIRA_URI => $request->getStr(self::PROPERTY_JIRA_URI), self::PROPERTY_REPORT_LINK => $request->getInt(self::PROPERTY_REPORT_LINK, 0), self::PROPERTY_REPORT_COMMENT => $request->getInt(self::PROPERTY_REPORT_COMMENT, 0));
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
$user = $request->getUser();
$latest_conpherences = array();
$latest_participant = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit(6)->execute();
if ($latest_participant) {
$conpherence_phids = mpull($latest_participant, 'getConpherencePHID');
$latest_conpherences = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs($conpherence_phids)->needCropPics(true)->needParticipantCache(true)->execute();
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
$latest_conpherences = array_select_keys($latest_conpherences, $conpherence_phids);
}
$conpherence = null;
$should_404 = false;
if ($request->getInt('id')) {
$conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($request->getInt('id')))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne();
$should_404 = true;
} else {
if ($latest_participant) {
$participant = head($latest_participant);
$conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs(array($participant->getConpherencePHID()))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne();
$should_404 = true;
}
}
$durable_column = id(new ConpherenceDurableColumnView())->setUser($user)->setVisible(true);
if (!$conpherence) {
if ($should_404) {
return new Aphront404Response();
}
$conpherence_id = null;
$conpherence_phid = null;
$latest_transaction_id = null;
$can_edit = false;
} else {
$this->setConpherence($conpherence);
$participant = $conpherence->getParticipant($user->getPHID());
$transactions = $conpherence->getTransactions();
$latest_transaction = head($transactions);
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$participant->markUpToDate($conpherence, $latest_transaction);
unset($write_guard);
$draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID());
$durable_column->setDraft($draft)->setSelectedConpherence($conpherence)->setConpherences($latest_conpherences);
$conpherence_id = $conpherence->getID();
$conpherence_phid = $conpherence->getPHID();
$latest_transaction_id = $latest_transaction->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
}
$dropdown_query = id(new AphlictDropdownDataQuery())->setViewer($user);
$dropdown_query->execute();
$response = array('content' => hsprintf('%s', $durable_column), 'threadID' => $conpherence_id, 'threadPHID' => $conpherence_phid, 'latestTransactionID' => $latest_transaction_id, 'canEdit' => $can_edit, 'aphlictDropdownData' => array($dropdown_query->getNotificationData(), $dropdown_query->getConpherenceData()));
return id(new AphrontAjaxResponse())->setContent($response);
}
示例5: handleRequest
/**
* @phutil-external-symbol class PhabricatorStartup
*/
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
// NOTE: Throws if valid CSRF token is not present in the request.
$request->validateCSRF();
$name = $request->getStr('name');
$file_phid = $request->getStr('phid');
// If there's no explicit view policy, make it very restrictive by default.
// This is the correct policy for files dropped onto objects during
// creation, comment and edit flows.
$view_policy = $request->getStr('viewPolicy');
if (!$view_policy) {
$view_policy = $viewer->getPHID();
}
$is_chunks = $request->getBool('querychunks');
if ($is_chunks) {
$params = array('filePHID' => $file_phid);
$result = id(new ConduitCall('file.querychunks', $params))->setUser($viewer)->execute();
return id(new AphrontAjaxResponse())->setContent($result);
}
$is_allocate = $request->getBool('allocate');
if ($is_allocate) {
$params = array('name' => $name, 'contentLength' => $request->getInt('length'), 'viewPolicy' => $view_policy);
$result = id(new ConduitCall('file.allocate', $params))->setUser($viewer)->execute();
$file_phid = $result['filePHID'];
if ($file_phid) {
$file = $this->loadFile($file_phid);
$result += $file->getDragAndDropDictionary();
}
return id(new AphrontAjaxResponse())->setContent($result);
}
// Read the raw request data. We're either doing a chunk upload or a
// vanilla upload, so we need it.
$data = PhabricatorStartup::getRawInput();
$is_chunk_upload = $request->getBool('uploadchunk');
if ($is_chunk_upload) {
$params = array('filePHID' => $file_phid, 'byteStart' => $request->getInt('byteStart'), 'data' => $data);
$result = id(new ConduitCall('file.uploadchunk', $params))->setUser($viewer)->execute();
$file = $this->loadFile($file_phid);
if ($file->getIsPartial()) {
$result = array();
} else {
$result = array('complete' => true) + $file->getDragAndDropDictionary();
}
return id(new AphrontAjaxResponse())->setContent($result);
}
$file = PhabricatorFile::newFromXHRUpload($data, array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true));
$result = $file->getDragAndDropDictionary();
return id(new AphrontAjaxResponse())->setContent($result);
}
示例6: handleRequest
public function handleRequest(AphrontRequest $request)
{
$user = $request->getUser();
$id = $request->getURIData('id');
if ($id) {
$post = id(new PhamePostQuery())->setViewer($user)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$post) {
return new Aphront404Response();
}
$cancel_uri = $this->getApplicationURI('/post/view/' . $id . '/');
$submit_button = pht('Save Changes');
$page_title = pht('Edit Post');
} else {
$blog = id(new PhameBlogQuery())->setViewer($user)->withIDs(array($request->getInt('blog')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_JOIN))->executeOne();
if (!$blog) {
return new Aphront404Response();
}
$post = PhamePost::initializePost($user, $blog);
$cancel_uri = $this->getApplicationURI('/blog/view/' . $blog->getID() . '/');
$submit_button = pht('Save Draft');
$page_title = pht('Create Post');
}
$title = $post->getTitle();
$phame_title = $post->getPhameTitle();
$body = $post->getBody();
$comments_widget = $post->getCommentsWidget();
$e_title = true;
$e_phame_title = true;
$validation_exception = null;
if ($request->isFormPost()) {
$title = $request->getStr('title');
$phame_title = $request->getStr('phame_title');
$phame_title = PhabricatorSlug::normalize($phame_title);
$body = $request->getStr('body');
$comments_widget = $request->getStr('comments_widget');
$xactions = array(id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_TITLE)->setNewValue($title), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_PHAME_TITLE)->setNewValue($phame_title), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_BODY)->setNewValue($body), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_COMMENTS_WIDGET)->setNewValue($comments_widget));
$editor = id(new PhamePostEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($post, $xactions);
$uri = $this->getApplicationURI('/post/view/' . $post->getID() . '/');
return id(new AphrontRedirectResponse())->setURI($uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_title = $validation_exception->getShortMessage(PhamePostTransaction::TYPE_TITLE);
$e_phame_title = $validation_exception->getShortMessage(PhamePostTransaction::TYPE_PHAME_TITLE);
}
}
$handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($post->getBlogPHID()))->executeOne();
$form = id(new AphrontFormView())->setUser($user)->addHiddenInput('blog', $request->getInt('blog'))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Blog'))->setValue($handle->renderLink()))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Title'))->setName('title')->setValue($title)->setID('post-title')->setError($e_title))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Phame Title'))->setName('phame_title')->setValue(rtrim($phame_title, '/'))->setID('post-phame-title')->setCaption(pht('Up to 64 alphanumeric characters ' . 'with underscores for spaces. ' . 'Formatting is enforced.'))->setError($e_phame_title))->appendChild(id(new PhabricatorRemarkupControl())->setLabel(pht('Body'))->setName('body')->setValue($body)->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setID('post-body')->setUser($user)->setDisableMacros(true))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Comments Widget'))->setName('comments_widget')->setvalue($comments_widget)->setOptions($post->getCommentsWidgetOptionsForSelect()))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($submit_button));
$loading = phutil_tag_div('aphront-panel-preview-loading-text', pht('Loading preview...'));
$preview_panel = phutil_tag_div('aphront-panel-preview', array(phutil_tag_div('phame-post-preview-header', pht('Post Preview')), phutil_tag('div', array('id' => 'post-preview'), $loading)));
require_celerity_resource('phame-css');
Javelin::initBehavior('phame-post-preview', array('preview' => 'post-preview', 'body' => 'post-body', 'title' => 'post-title', 'phame_title' => 'post-phame-title', 'uri' => '/phame/post/preview/'));
$form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setValidationException($validation_exception)->setForm($form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($page_title, $this->getApplicationURI('/post/view/' . $id . '/'));
$nav = $this->renderSideNavFilterView(null);
$nav->appendChild(array($crumbs, $form_box, $preview_panel));
return $this->buildApplicationPage($nav, array('title' => $page_title));
}
示例7: processRequest
public function processRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$preferences = $this->getPreferences();
$notifications_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY;
$notifications_value = $preferences->getSettingValue($notifications_key);
if ($request->isFormPost()) {
$this->writeSetting($preferences, $notifications_key, $request->getInt($notifications_key));
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
}
$title = pht('Desktop Notifications');
$control_id = celerity_generate_unique_node_id();
$status_id = celerity_generate_unique_node_id();
$browser_status_id = celerity_generate_unique_node_id();
$cancel_ask = pht('The dialog asking for permission to send desktop notifications was ' . 'closed without granting permission. Only application notifications ' . 'will be sent.');
$accept_ask = pht('Click "Save Preference" to persist these changes.');
$reject_ask = pht('Permission for desktop notifications was denied. Only application ' . 'notifications will be sent.');
$no_support = pht('This web browser does not support desktop notifications. Only ' . 'application notifications will be sent for this browser regardless of ' . 'this preference.');
$default_status = phutil_tag('span', array(), array(pht('This browser has not yet granted permission to send desktop ' . 'notifications for this Phabricator instance.'), phutil_tag('br'), phutil_tag('br'), javelin_tag('button', array('sigil' => 'desktop-notifications-permission-button', 'class' => 'green'), pht('Grant Permission'))));
$granted_status = phutil_tag('span', array(), pht('This browser has been granted permission to send desktop ' . 'notifications for this Phabricator instance.'));
$denied_status = phutil_tag('span', array(), pht('This browser has denied permission to send desktop notifications ' . 'for this Phabricator instance. Consult your browser settings / ' . 'documentation to figure out how to clear this setting, do so, ' . 'and then re-visit this page to grant permission.'));
$status_box = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setID($status_id)->setIsHidden(true)->appendChild($accept_ask);
$control_config = array('controlID' => $control_id, 'statusID' => $status_id, 'browserStatusID' => $browser_status_id, 'defaultMode' => 0, 'desktopMode' => 1, 'cancelAsk' => $cancel_ask, 'grantedAsk' => $accept_ask, 'deniedAsk' => $reject_ask, 'defaultStatus' => $default_status, 'deniedStatus' => $denied_status, 'grantedStatus' => $granted_status, 'noSupport' => $no_support);
$form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel($title)->setControlID($control_id)->setName($notifications_key)->setValue($notifications_value)->setOptions(array(1 => pht('Send Desktop Notifications Too'), 0 => pht('Send Application Notifications Only')))->setCaption(pht('Should Phabricator send desktop notifications? These are sent ' . 'in addition to the notifications within the Phabricator ' . 'application.'))->initBehavior('desktop-notifications-control', $control_config))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Preference')));
$test_button = id(new PHUIButtonView())->setTag('a')->setWorkflow(true)->setText(pht('Send Test Notification'))->setHref('/notification/test/')->setIcon('fa-exclamation-triangle');
$form_box = id(new PHUIObjectBoxView())->setHeader(id(new PHUIHeaderView())->setHeader(pht('Desktop Notifications'))->addActionLink($test_button))->setForm($form)->setInfoView($status_box)->setFormSaved($request->getBool('saved'));
$browser_status_box = id(new PHUIInfoView())->setID($browser_status_id)->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setIsHidden(true)->appendChild($default_status);
return array($form_box, $browser_status_box);
}
示例8: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$blueprint) {
return new Aphront404Response();
}
$title = $blueprint->getBlueprintName();
$header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($blueprint);
$actions = $this->buildActionListView($blueprint);
$properties = $this->buildPropertyListView($blueprint, $actions);
$blueprint_uri = 'blueprint/' . $blueprint->getID() . '/';
$blueprint_uri = $this->getApplicationURI($blueprint_uri);
$resources = id(new DrydockResourceQuery())->withBlueprintPHIDs(array($blueprint->getPHID()))->setViewer($viewer)->execute();
$resource_list = id(new DrydockResourceListView())->setUser($viewer)->setResources($resources)->render();
$resource_list->setNoDataString(pht('This blueprint has no resources.'));
$pager = new PHUIPagerView();
$pager->setURI(new PhutilURI($blueprint_uri), 'offset');
$pager->setOffset($request->getInt('offset'));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$field_list = PhabricatorCustomField::getObjectFields($blueprint, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($viewer)->readFieldsFromStorage($blueprint);
$field_list->appendFieldsToPropertyList($blueprint, $viewer, $properties);
$timeline = $this->buildTransactionTimeline($blueprint, new DrydockBlueprintTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(array($crumbs, $object_box, $resource_list, $timeline), array('title' => $title));
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$question_id = $request->getInt('question_id');
$question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($question_id))->needAnswers(true)->executeOne();
if (!$question) {
return new Aphront404Response();
}
$content = $request->getStr('answer');
if (!strlen(trim($content))) {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Empty Answer'))->appendChild(phutil_tag('p', array(), pht('Your answer must not be empty.')))->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$answer = PonderAnswer::initializeNewAnswer($viewer, $question);
// Question Editor
$xactions = array();
$xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERS)->setNewValue(array('+' => array(array('answer' => $answer))));
$editor = id(new PonderQuestionEditor())->setActor($viewer)->setContentSourceFromRequest($request);
$editor->applyTransactions($question, $xactions);
// Answer Editor
$template = id(new PonderAnswerTransaction());
$xactions = array();
$xactions[] = id(clone $template)->setTransactionType(PonderAnswerTransaction::TYPE_QUESTION_ID)->setNewValue($question->getID());
$xactions[] = id(clone $template)->setTransactionType(PonderAnswerTransaction::TYPE_CONTENT)->setNewValue($content);
$editor = id(new PonderAnswerEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
$editor->applyTransactions($answer, $xactions);
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$pager = new PHUIPagerView();
$pager->setURI($request->getRequestURI(), 'page');
$pager->setOffset($request->getInt('page'));
$query = id(new PhabricatorTokenReceiverQuery());
$objects = $query->setViewer($viewer)->executeWithOffsetPager($pager);
$counts = $query->getTokenCounts();
$handles = array();
$phids = array();
if ($counts) {
$phids = mpull($objects, 'getPHID');
$handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
}
$list = new PHUIObjectItemListView();
foreach ($phids as $object) {
$count = idx($counts, $object, 0);
$item = id(new PHUIObjectItemView());
$handle = $handles[$object];
$item->setHeader($handle->getFullName());
$item->setHref($handle->getURI());
$item->addAttribute(pht('Tokens: %s', $count));
$list->addItem($item);
}
$title = pht('Token Leader Board');
$box = id(new PHUIObjectBoxView())->setHeaderText($title)->setObjectList($list);
$nav = $this->buildSideNav();
$nav->setCrumbs($this->buildApplicationCrumbs()->addTextCrumb($title));
$nav->selectFilter('leaders/');
$nav->appendChild($box);
$nav->appendChild($pager);
return $this->newPage()->setTitle($title)->appendChild($nav);
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$post = id(new PhamePostQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
if (!$post) {
return new Aphront404Response();
}
$view_uri = '/post/view/' . $post->getID() . '/';
$view_uri = $this->getApplicationURI($view_uri);
if ($request->isFormPost()) {
$blog = id(new PhameBlogQuery())->setViewer($viewer)->withIDs(array($request->getInt('blog')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if ($blog) {
$post->setBlogPHID($blog->getPHID());
$post->save();
return id(new AphrontRedirectResponse())->setURI($view_uri . '?moved=1');
}
}
$blogs = id(new PhameBlogQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->execute();
$options = mpull($blogs, 'getName', 'getID');
asort($options);
$selected_value = null;
if ($post && $post->getBlog()) {
$selected_value = $post->getBlog()->getID();
}
$form = id(new PHUIFormLayoutView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Blog'))->setName('blog')->setOptions($options)->setValue($selected_value));
return $this->newDialog()->setTitle(pht('Move Post'))->appendChild($form)->addSubmitButton(pht('Move Post'))->addCancelButton($view_uri);
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$user = $request->getUser();
$nav = $this->renderSideNavFilterView(null);
$filter = $request->getURIData('filter');
$filter = $nav->selectFilter('blog/' . $filter, 'blog/user');
$query = id(new PhameBlogQuery())->setViewer($user);
switch ($filter) {
case 'blog/all':
$title = pht('All Blogs');
$nodata = pht('No blogs have been created.');
break;
case 'blog/user':
$title = pht('Joinable Blogs');
$nodata = pht('There are no blogs you can contribute to.');
$query->requireCapabilities(array(PhabricatorPolicyCapability::CAN_JOIN));
break;
default:
throw new Exception(pht("Unknown filter '%s'!", $filter));
}
$pager = id(new AphrontPagerView())->setURI($request->getRequestURI(), 'offset')->setOffset($request->getInt('offset'));
$blogs = $query->executeWithOffsetPager($pager);
$blog_list = $this->renderBlogList($blogs, $user, $nodata);
$blog_list->setPager($pager);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, $this->getApplicationURI());
$nav->appendChild(array($crumbs, $blog_list));
return $this->buildApplicationPage($nav, array('title' => $title));
}
示例13: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$limit = 500;
$offset = $request->getInt('offset', 0);
$drequest = $this->getDiffusionRequest();
$branch = $drequest->loadBranch();
$messages = $this->loadLintMessages($branch, $limit, $offset);
$is_dir = substr('/' . $drequest->getPath(), -1) == '/';
$authors = $this->loadViewerHandles(ipull($messages, 'authorPHID'));
$rows = array();
foreach ($messages as $message) {
$path = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'lint', 'path' => $message['path']))), substr($message['path'], strlen($drequest->getPath()) + 1));
$line = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'path' => $message['path'], 'line' => $message['line'], 'commit' => $branch->getLintCommit()))), $message['line']);
$author = $message['authorPHID'];
if ($author && $authors[$author]) {
$author = $authors[$author]->renderLink();
}
$rows[] = array($path, $line, $author, ArcanistLintSeverity::getStringForSeverity($message['severity']), $message['name'], $message['description']);
}
$table = id(new AphrontTableView($rows))->setHeaders(array(pht('Path'), pht('Line'), pht('Author'), pht('Severity'), pht('Name'), pht('Description')))->setColumnClasses(array('', 'n'))->setColumnVisibility(array($is_dir));
$content = array();
$pager = id(new AphrontPagerView())->setPageSize($limit)->setOffset($offset)->setHasMorePages(count($messages) >= $limit)->setURI($request->getRequestURI(), 'offset');
$content[] = id(new PHUIObjectBoxView())->setHeaderText(pht('Lint Details'))->appendChild($table);
$crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'lint'));
return $this->buildApplicationPage(array($crumbs, $content, $pager), array('title' => array(pht('Lint'), $drequest->getRepository()->getCallsign())));
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$resource = id(new DrydockResourceQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$resource) {
return new Aphront404Response();
}
$title = pht('Resource %s %s', $resource->getID(), $resource->getName());
$header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($resource)->setHeader($title);
$actions = $this->buildActionListView($resource);
$properties = $this->buildPropertyListView($resource, $actions);
$resource_uri = 'resource/' . $resource->getID() . '/';
$resource_uri = $this->getApplicationURI($resource_uri);
$pager = new PHUIPagerView();
$pager->setURI(new PhutilURI($resource_uri), 'offset');
$pager->setOffset($request->getInt('offset'));
$logs = id(new DrydockLogQuery())->setViewer($viewer)->withResourceIDs(array($resource->getID()))->executeWithOffsetPager($pager);
$log_table = id(new DrydockLogListView())->setUser($viewer)->setLogs($logs)->render();
$log_table->appendChild($pager);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Resource %d', $resource->getID()));
$locks = $this->buildLocksTab($resource->getPHID());
$commands = $this->buildCommandsTab($resource->getPHID());
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties, pht('Properties'))->addPropertyList($locks, pht('Slot Locks'))->addPropertyList($commands, pht('Commands'));
$lease_box = $this->buildLeaseBox($resource);
$log_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Resource Logs'))->setTable($log_table);
return $this->buildApplicationPage(array($crumbs, $object_box, $lease_box, $log_box), array('title' => $title));
}
示例15: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$event) {
return new Aphront404Response();
}
if (!$request->validateCSRF()) {
return new Aphront400Response();
}
if ($event->getIsAllDay()) {
return new Aphront400Response();
}
$xactions = array();
$duration = $event->getDuration();
$start = $request->getInt('start');
$start_value = id(AphrontFormDateControlValue::newFromEpoch($viewer, $start));
$end = $start + $duration;
$end_value = id(AphrontFormDateControlValue::newFromEpoch($viewer, $end));
$xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE)->setNewValue($start_value);
$xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE)->setNewValue($end_value);
$editor = id(new PhabricatorCalendarEventEditor())->setActor($viewer)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
$xactions = $editor->applyTransactions($event, $xactions);
return id(new AphrontReloadResponse());
}