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


PHP AphrontRequest::isAjax方法代码示例

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


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

示例1: 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

示例2: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $poll = id(new PhabricatorSlowvoteQuery())->setViewer($viewer)->withIDs(array($id))->needOptions(true)->needChoices(true)->needViewerChoices(true)->executeOne();
     if (!$poll) {
         return new Aphront404Response();
     }
     $poll_view = id(new SlowvoteEmbedView())->setUser($viewer)->setPoll($poll);
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent(array('pollID' => $poll->getID(), 'contentHTML' => $poll_view->render()));
     }
     $header_icon = $poll->getIsClosed() ? 'fa-ban' : 'fa-circle-o';
     $header_name = $poll->getIsClosed() ? pht('Closed') : pht('Open');
     $header_color = $poll->getIsClosed() ? 'dark' : 'bluegrey';
     $header = id(new PHUIHeaderView())->setHeader($poll->getQuestion())->setUser($viewer)->setStatus($header_icon, $header_color, $header_name)->setPolicyObject($poll)->setHeaderIcon('fa-bar-chart');
     $actions = $this->buildActionView($poll);
     $properties = $this->buildPropertyView($poll);
     $subheader = $this->buildSubheaderView($poll);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb('V' . $poll->getID());
     $crumbs->setBorder(true);
     $timeline = $this->buildTransactionTimeline($poll, new PhabricatorSlowvoteTransactionQuery());
     $add_comment = $this->buildCommentForm($poll);
     $poll_content = array($poll_view, $timeline, $add_comment);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setMainColumn($poll_content)->setPropertyList($properties)->setActionList($actions);
     return $this->newPage()->setTitle('V' . $poll->getID() . ' ' . $poll->getQuestion())->setCrumbs($crumbs)->setPageObjectPHIDs(array($poll->getPHID()))->appendChild(array($view));
 }
开发者ID:Houzz,项目名称:phabricator,代码行数:28,代码来源:PhabricatorSlowvotePollController.php

示例3: 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();
     $objects = mpull($objects, null, 'getPHID');
     $extensions = PhabricatorHovercardEngineExtension::getAllEnabledExtensions();
     $extension_maps = array();
     foreach ($extensions as $key => $extension) {
         $extension->setViewer($viewer);
         $extension_phids = array();
         foreach ($objects as $phid => $object) {
             if ($extension->canRenderObjectHovercard($object)) {
                 $extension_phids[$phid] = $phid;
             }
         }
         $extension_maps[$key] = $extension_phids;
     }
     $extension_data = array();
     foreach ($extensions as $key => $extension) {
         $extension_phids = $extension_maps[$key];
         if (!$extension_phids) {
             unset($extensions[$key]);
             continue;
         }
         $extension_data[$key] = $extension->willRenderHovercards(array_select_keys($objects, $extension_phids));
     }
     $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);
             foreach ($extension_maps as $key => $extension_phids) {
                 if (isset($extension_phids[$phid])) {
                     $extensions[$key]->renderHovercard($hovercard, $handle, $object, $extension_data[$key]);
                 }
             }
         }
         $cards[$phid] = $hovercard;
     }
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent(array('cards' => $cards));
     }
     foreach ($cards as $key => $hovercard) {
         $cards[$key] = phutil_tag('div', array('class' => 'ml'), $hovercard);
     }
     return $this->newPage()->appendChild($cards)->setShowFooter(false);
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:51,代码来源:PhabricatorSearchHovercardController.php

示例4: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $panel = id(new PhabricatorDashboardPanelQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$panel) {
         return new Aphront404Response();
     }
     if ($request->isAjax()) {
         $parent_phids = $request->getStrList('parentPanelPHIDs', null);
         if ($parent_phids === null) {
             throw new Exception(pht('Required parameter `parentPanelPHIDs` is not present in ' . 'request.'));
         }
     } else {
         $parent_phids = array();
     }
     $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())->setViewer($viewer)->setPanel($panel)->setParentPanelPHIDs($parent_phids)->setHeaderMode($request->getStr('headerMode'))->setDashboardID($request->getInt('dashboardID'))->renderPanel();
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent(array('panelMarkup' => hsprintf('%s', $rendered_panel)));
     }
     $crumbs = $this->buildApplicationCrumbs()->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'))->addTextCrumb($panel->getMonogram(), '/' . $panel->getMonogram())->addTextCrumb(pht('Standalone View'));
     $view = id(new PHUIBoxView())->addClass('dashboard-view')->appendChild($rendered_panel);
     return $this->buildApplicationPage(array($crumbs, $view), array('title' => array(pht('Panel'), $panel->getName())));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:24,代码来源:PhabricatorDashboardPanelRenderController.php

示例5: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $poll = id(new PhabricatorSlowvoteQuery())->setViewer($viewer)->withIDs(array($id))->needOptions(true)->needViewerChoices(true)->executeOne();
     if (!$poll) {
         return new Aphront404Response();
     }
     if ($poll->getIsClosed()) {
         return new Aphront400Response();
     }
     $options = $poll->getOptions();
     $viewer_choices = $poll->getViewerChoices($viewer);
     $old_votes = mpull($viewer_choices, null, 'getOptionID');
     if ($request->isAjax()) {
         $vote = $request->getInt('vote');
         $votes = array_keys($old_votes);
         $votes = array_fuse($votes, $votes);
         if ($poll->getMethod() == PhabricatorSlowvotePoll::METHOD_PLURALITY) {
             if (idx($votes, $vote, false)) {
                 $votes = array();
             } else {
                 $votes = array($vote);
             }
         } else {
             if (idx($votes, $vote, false)) {
                 unset($votes[$vote]);
             } else {
                 $votes[$vote] = $vote;
             }
         }
         $this->updateVotes($viewer, $poll, $old_votes, $votes);
         $updated_choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere('pollID = %d AND authorPHID = %s', $poll->getID(), $viewer->getPHID());
         $embed = id(new SlowvoteEmbedView())->setPoll($poll)->setOptions($options)->setViewerChoices($updated_choices);
         return id(new AphrontAjaxResponse())->setContent(array('pollID' => $poll->getID(), 'contentHTML' => $embed->render()));
     }
     if (!$request->isFormPost()) {
         return id(new Aphront404Response());
     }
     $votes = $request->getArr('vote');
     $votes = array_fuse($votes, $votes);
     $this->updateVotes($viewer, $poll, $old_votes, $votes);
     return id(new AphrontRedirectResponse())->setURI('/V' . $poll->getID());
 }
开发者ID:pugong,项目名称:phabricator,代码行数:44,代码来源:PhabricatorSlowvoteVoteController.php

示例6: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $operation = id(new DrydockRepositoryOperationQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$operation) {
         return new Aphront404Response();
     }
     $id = $operation->getID();
     $status_view = id(new DrydockRepositoryOperationStatusView())->setUser($viewer)->setOperation($operation);
     if ($request->isAjax()) {
         $payload = array('markup' => $status_view->renderUnderwayState(), 'isUnderway' => $operation->isUnderway());
         return id(new AphrontAjaxResponse())->setContent($payload);
     }
     $title = pht('Repository Operation %d', $id);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Operations'), $this->getApplicationURI('operation/'));
     $crumbs->addTextCrumb($title);
     return $this->newPage()->setTitle(pht('Status'))->setCrumbs($crumbs)->appendChild($status_view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:20,代码来源:DrydockRepositoryOperationStatusController.php

示例7: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     // Users can end up on this page directly by following links in email,
     // so we try to make it somewhat reasonable as a standalone page.
     $viewer = $this->getViewer();
     $phid = $request->getURIData('phid');
     $xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($phid))->setViewer($viewer)->executeOne();
     if (!$xaction) {
         return new Aphront404Response();
     }
     $details = $xaction->renderChangeDetails($viewer);
     $object_phid = $xaction->getObjectPHID();
     $handles = $viewer->loadHandles(array($object_phid));
     $handle = $handles[$object_phid];
     $this->objectHandle = $handle;
     $cancel_uri = $handle->getURI();
     if ($request->isAjax()) {
         $button_text = pht('Done');
     } else {
         $button_text = pht('Continue');
     }
     return $this->newDialog()->setTitle(pht('Change Details'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendChild($details)->addCancelButton($cancel_uri, $button_text);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:23,代码来源:PhabricatorApplicationTransactionDetailController.php

示例8: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     if ($viewer->isLoggedIn()) {
         // Kick the user home if they are already logged in.
         return id(new AphrontRedirectResponse())->setURI('/');
     }
     if ($request->isAjax()) {
         return $this->processAjaxRequest();
     }
     if ($request->isConduit()) {
         return $this->processConduitRequest();
     }
     // If the user gets this far, they aren't logged in, so if they have a
     // user session token we can conclude that it's invalid: if it was valid,
     // they'd have been logged in above and never made it here. Try to clear
     // it and warn the user they may need to nuke their cookies.
     $session_token = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
     if (strlen($session_token)) {
         $kind = PhabricatorAuthSessionEngine::getSessionKindFromToken($session_token);
         switch ($kind) {
             case PhabricatorAuthSessionEngine::KIND_ANONYMOUS:
                 // If this is an anonymous session. It's expected that they won't
                 // be logged in, so we can just continue.
                 break;
             default:
                 // The session cookie is invalid, so clear it.
                 $request->clearCookie(PhabricatorCookies::COOKIE_USERNAME);
                 $request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
                 return $this->renderError(pht('Your login session is invalid. Try reloading the page and ' . 'logging in again. If that does not work, clear your browser ' . 'cookies.'));
         }
     }
     $providers = PhabricatorAuthProvider::getAllEnabledProviders();
     foreach ($providers as $key => $provider) {
         if (!$provider->shouldAllowLogin()) {
             unset($providers[$key]);
         }
     }
     if (!$providers) {
         if ($this->isFirstTimeSetup()) {
             // If this is a fresh install, let the user register their admin
             // account.
             return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/register/'));
         }
         return $this->renderError(pht('This Phabricator install is not configured with any enabled ' . 'authentication providers which can be used to log in. If you ' . 'have accidentally locked yourself out by disabling all providers, ' . 'you can use `%s` to recover access to an administrative account.', 'phabricator/bin/auth recover <username>'));
     }
     $next_uri = $request->getStr('next');
     if (!strlen($next_uri)) {
         if ($this->getDelegatingController()) {
             // Only set a next URI from the request path if this controller was
             // delegated to, which happens when a user tries to view a page which
             // requires them to login.
             // If this controller handled the request directly, we're on the main
             // login page, and never want to redirect the user back here after they
             // login.
             $next_uri = (string) $this->getRequest()->getRequestURI();
         }
     }
     if (!$request->isFormPost()) {
         if (strlen($next_uri)) {
             PhabricatorCookies::setNextURICookie($request, $next_uri);
         }
         PhabricatorCookies::setClientIDCookie($request);
     }
     if (!$request->getURIData('loggedout') && count($providers) == 1) {
         $auto_login_provider = head($providers);
         $auto_login_config = $auto_login_provider->getProviderConfig();
         if ($auto_login_provider instanceof PhabricatorPhabricatorAuthProvider && $auto_login_config->getShouldAutoLogin()) {
             $auto_login_adapter = $provider->getAdapter();
             $auto_login_adapter->setState($provider->getAuthCSRFCode($request));
             return id(new AphrontRedirectResponse())->setIsExternal(true)->setURI($provider->getAdapter()->getAuthenticateURI());
         }
     }
     $invite = $this->loadInvite();
     $not_buttons = array();
     $are_buttons = array();
     $providers = msort($providers, 'getLoginOrder');
     foreach ($providers as $provider) {
         if ($invite) {
             $form = $provider->buildInviteForm($this);
         } else {
             $form = $provider->buildLoginForm($this);
         }
         if ($provider->isLoginFormAButton()) {
             $are_buttons[] = $form;
         } else {
             $not_buttons[] = $form;
         }
     }
     $out = array();
     $out[] = $not_buttons;
     if ($are_buttons) {
         require_celerity_resource('auth-css');
         foreach ($are_buttons as $key => $button) {
             $are_buttons[$key] = phutil_tag('div', array('class' => 'phabricator-login-button mmb'), $button);
         }
         // If we only have one button, add a second pretend button so that we
         // always have two columns. This makes it easier to get the alignments
         // looking reasonable.
         if (count($are_buttons) == 1) {
//.........这里部分代码省略.........
开发者ID:fengshao0907,项目名称:phabricator,代码行数:101,代码来源:PhabricatorAuthStartController.php

示例9: newEditResponse

 protected function newEditResponse(AphrontRequest $request, $object, array $xactions)
 {
     if ($request->isAjax()) {
         // Reload the task to make sure we pick up the final task state.
         $viewer = $this->getViewer();
         $task = id(new ManiphestTaskQuery())->setViewer($viewer)->withIDs(array($object->getID()))->needSubscriberPHIDs(true)->needProjectPHIDs(true)->executeOne();
         switch ($request->getStr('responseType')) {
             case 'card':
                 return $this->buildCardResponse($task);
             default:
                 return $this->buildListResponse($task);
         }
     }
     return parent::newEditResponse($request, $object, $xactions);
 }
开发者ID:fuding,项目名称:phabricator,代码行数:15,代码来源:ManiphestEditEngine.php

示例10: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $conpherence_id = $request->getURIData('id');
     if (!$conpherence_id) {
         return new Aphront404Response();
     }
     $query = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->needProfileImage(true)->needParticipantCache(true)->needTransactions(true)->setTransactionLimit($this->getMainQueryLimit());
     $before_transaction_id = $request->getInt('oldest_transaction_id');
     $after_transaction_id = $request->getInt('newest_transaction_id');
     $old_message_id = $request->getURIData('messageID');
     if ($before_transaction_id && ($old_message_id || $after_transaction_id)) {
         throw new Aphront400Response();
     }
     if ($old_message_id && $after_transaction_id) {
         throw new Aphront400Response();
     }
     $marker_type = 'older';
     if ($before_transaction_id) {
         $query->setBeforeTransactionID($before_transaction_id);
     }
     if ($old_message_id) {
         $marker_type = 'olderandnewer';
         $query->setAfterTransactionID($old_message_id - 1);
     }
     if ($after_transaction_id) {
         $marker_type = 'newer';
         $query->setAfterTransactionID($after_transaction_id);
     }
     $conpherence = $query->executeOne();
     if (!$conpherence) {
         return new Aphront404Response();
     }
     $this->setConpherence($conpherence);
     $transactions = $this->getNeededTransactions($conpherence, $old_message_id);
     $latest_transaction = head($transactions);
     $participant = $conpherence->getParticipantIfExists($user->getPHID());
     if ($participant) {
         if (!$participant->isUpToDate($conpherence)) {
             $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
             $participant->markUpToDate($conpherence, $latest_transaction);
             $user->clearCacheData(PhabricatorUserMessageCountCacheType::KEY_COUNT);
             unset($write_guard);
         }
     }
     $data = ConpherenceTransactionRenderer::renderTransactions($user, $conpherence, $marker_type);
     $messages = ConpherenceTransactionRenderer::renderMessagePaneContent($data['transactions'], $data['oldest_transaction_id'], $data['newest_transaction_id']);
     if ($before_transaction_id || $after_transaction_id) {
         $header = null;
         $form = null;
         $content = array('transactions' => $messages);
     } else {
         $policy_objects = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($conpherence)->execute();
         $header = $this->buildHeaderPaneContent($conpherence, $policy_objects);
         $search = $this->buildSearchForm();
         $form = $this->renderFormContent();
         $content = array('header' => $header, 'search' => $search, 'transactions' => $messages, 'form' => $form);
     }
     $d_data = $conpherence->getDisplayData($user);
     $content['title'] = $title = $d_data['title'];
     if ($request->isAjax()) {
         $dropdown_query = id(new AphlictDropdownDataQuery())->setViewer($user);
         $dropdown_query->execute();
         $content['threadID'] = $conpherence->getID();
         $content['threadPHID'] = $conpherence->getPHID();
         $content['latestTransactionID'] = $data['latest_transaction_id'];
         $content['canEdit'] = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
         $content['aphlictDropdownData'] = array($dropdown_query->getNotificationData(), $dropdown_query->getConpherenceData());
         return id(new AphrontAjaxResponse())->setContent($content);
     }
     $can_join = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_JOIN);
     $layout = id(new ConpherenceLayoutView())->setUser($user)->setBaseURI($this->getApplicationURI())->setThread($conpherence)->setHeader($header)->setSearch($search)->setMessages($messages)->setReplyForm($form)->setLatestTransactionID($data['latest_transaction_id'])->setRole('thread');
     $participating = $conpherence->getParticipantIfExists($user->getPHID());
     if (!$user->isLoggedIn()) {
         $layout->addClass('conpherence-no-pontificate');
     }
     return $this->newPage()->setTitle($title)->setPageObjectPHIDs(array($conpherence->getPHID()))->appendChild($layout);
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:78,代码来源:ConpherenceViewController.php

示例11: processPanelTypeRequest

 private function processPanelTypeRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $types = PhabricatorDashboardPanelType::getAllPanelTypes();
     $v_type = null;
     $errors = array();
     if ($request->isFormPost()) {
         $v_type = $request->getStr('type');
         if (!isset($types[$v_type])) {
             $errors[] = pht('You must select a type of panel to create.');
         }
     }
     $cancel_uri = $this->getApplicationURI('panel/');
     if (!$v_type) {
         $v_type = key($types);
     }
     $panel_types = id(new AphrontFormRadioButtonControl())->setName('type')->setValue($v_type);
     foreach ($types as $key => $type) {
         $panel_types->addButton($key, $type->getPanelTypeName(), $type->getPanelTypeDescription());
     }
     $form = id(new AphrontFormView())->setUser($viewer)->addHiddenInput('dashboardID', $request->getInt('dashboardID'))->addHiddenInput('column', $request->getInt('column'))->appendRemarkupInstructions(pht('Choose the type of dashboard panel to create:'))->appendChild($panel_types);
     if ($request->isAjax()) {
         return $this->newDialog()->setTitle(pht('Add New Panel'))->setWidth(AphrontDialogView::WIDTH_FORM)->setErrors($errors)->appendChild($form->buildLayoutView())->addCancelbutton($cancel_uri)->addSubmitButton(pht('Continue'));
     } else {
         $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($cancel_uri));
     }
     $title = pht('Create Dashboard Panel');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'));
     $crumbs->addTextCrumb(pht('New Panel'));
     $box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorDashboardPanelEditController.php

示例12: processDiffusionRequest

 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $drequest = $this->getDiffusionRequest();
     $viewer = $request->getUser();
     $before = $request->getStr('before');
     if ($before) {
         return $this->buildBeforeResponse($before);
     }
     $path = $drequest->getPath();
     $preferences = $viewer->loadPreferences();
     $show_blame = $request->getBool('blame', $preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME, false));
     $show_color = $request->getBool('color', $preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR, true));
     $view = $request->getStr('view');
     if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) {
         $preferences->setPreference(PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME, $show_blame);
         $preferences->setPreference(PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR, $show_color);
         $preferences->save();
         $uri = $request->getRequestURI()->alter('blame', null)->alter('color', null);
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     // We need the blame information if blame is on and we're building plain
     // text, or blame is on and this is an Ajax request. If blame is on and
     // this is a colorized request, we don't show blame at first (we ajax it
     // in afterward) so we don't need to query for it.
     $needs_blame = $show_blame && !$show_color || $show_blame && $request->isAjax();
     $params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'needsBlame' => $needs_blame);
     $byte_limit = null;
     if ($view !== 'raw') {
         $byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
         $time_limit = 10;
         $params += array('timeout' => $time_limit, 'byteLimit' => $byte_limit);
     }
     $file_content = DiffusionFileContent::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.filecontentquery', $params));
     $data = $file_content->getCorpus();
     if ($view === 'raw') {
         return $this->buildRawResponse($path, $data);
     }
     $this->loadLintMessages();
     $this->coverage = $drequest->loadCoverage();
     if ($byte_limit && strlen($data) == $byte_limit) {
         $corpus = $this->buildErrorCorpus(pht('This file is larger than %s byte(s), and too large to display ' . 'in the web UI.', $byte_limit));
     } else {
         if (ArcanistDiffUtils::isHeuristicBinaryFile($data)) {
             $file = $this->loadFileForData($path, $data);
             $file_uri = $file->getBestURI();
             if ($file->isViewableImage()) {
                 $corpus = $this->buildImageCorpus($file_uri);
             } else {
                 $corpus = $this->buildBinaryCorpus($file_uri, $data);
             }
         } else {
             // Build the content of the file.
             $corpus = $this->buildCorpus($show_blame, $show_color, $file_content, $needs_blame, $drequest, $path, $data);
         }
     }
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent($corpus);
     }
     require_celerity_resource('diffusion-source-css');
     // Render the page.
     $view = $this->buildActionView($drequest);
     $action_list = $this->enrichActionView($view, $drequest, $show_blame, $show_color);
     $properties = $this->buildPropertyView($drequest, $action_list);
     $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties);
     $content = array();
     $content[] = $object_box;
     $follow = $request->getStr('follow');
     if ($follow) {
         $notice = new PHUIInfoView();
         $notice->setSeverity(PHUIInfoView::SEVERITY_WARNING);
         $notice->setTitle(pht('Unable to Continue'));
         switch ($follow) {
             case 'first':
                 $notice->appendChild(pht('Unable to continue tracing the history of this file because ' . 'this commit is the first commit in the repository.'));
                 break;
             case 'created':
                 $notice->appendChild(pht('Unable to continue tracing the history of this file because ' . 'this commit created the file.'));
                 break;
         }
         $content[] = $notice;
     }
     $renamed = $request->getStr('renamed');
     if ($renamed) {
         $notice = new PHUIInfoView();
         $notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
         $notice->setTitle(pht('File Renamed'));
         $notice->appendChild(pht("File history passes through a rename from '%s' to '%s'.", $drequest->getPath(), $renamed));
         $content[] = $notice;
     }
     $content[] = $corpus;
     $content[] = $this->buildOpenRevisions();
     $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse'));
     $basename = basename($this->getDiffusionRequest()->getPath());
     return $this->buildApplicationPage(array($crumbs, $content), array('title' => $basename));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:95,代码来源:DiffusionBrowseFileController.php

示例13: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $conpherence_id = $request->getURIData('id');
     if (!$conpherence_id) {
         return new Aphront404Response();
     }
     $need_participants = false;
     $needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
     $action = $request->getStr('action', ConpherenceUpdateActions::METADATA);
     switch ($action) {
         case ConpherenceUpdateActions::REMOVE_PERSON:
             $person_phid = $request->getStr('remove_person');
             if ($person_phid != $user->getPHID()) {
                 $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
             }
             break;
         case ConpherenceUpdateActions::ADD_PERSON:
         case ConpherenceUpdateActions::METADATA:
             $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
             break;
         case ConpherenceUpdateActions::JOIN_ROOM:
             $needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
             break;
         case ConpherenceUpdateActions::NOTIFICATIONS:
             $need_participants = true;
             break;
         case ConpherenceUpdateActions::LOAD:
             break;
     }
     $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->needFilePHIDs(true)->needOrigPics(true)->needCropPics(true)->needParticipants($need_participants)->requireCapabilities($needed_capabilities)->executeOne();
     $latest_transaction_id = null;
     $response_mode = $request->isAjax() ? 'ajax' : 'redirect';
     $error_view = null;
     $e_file = array();
     $errors = array();
     $delete_draft = false;
     $xactions = array();
     if ($request->isFormPost() || $action == ConpherenceUpdateActions::LOAD) {
         $editor = id(new ConpherenceEditor())->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setActor($user);
         switch ($action) {
             case ConpherenceUpdateActions::DRAFT:
                 $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID());
                 $draft->setDraft($request->getStr('text'));
                 $draft->replaceOrDelete();
                 return new AphrontAjaxResponse();
             case ConpherenceUpdateActions::JOIN_ROOM:
                 $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => array($user->getPHID())));
                 $delete_draft = true;
                 $message = $request->getStr('text');
                 if ($message) {
                     $message_xactions = $editor->generateTransactionsFromText($user, $conpherence, $message);
                     $xactions = array_merge($xactions, $message_xactions);
                 }
                 // for now, just redirect back to the conpherence so everything
                 // will work okay...!
                 $response_mode = 'redirect';
                 break;
             case ConpherenceUpdateActions::MESSAGE:
                 $message = $request->getStr('text');
                 if (strlen($message)) {
                     $xactions = $editor->generateTransactionsFromText($user, $conpherence, $message);
                     $delete_draft = true;
                 } else {
                     $action = ConpherenceUpdateActions::LOAD;
                     $updated = false;
                     $response_mode = 'ajax';
                 }
                 break;
             case ConpherenceUpdateActions::ADD_PERSON:
                 $person_phids = $request->getArr('add_person');
                 if (!empty($person_phids)) {
                     $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $person_phids));
                 }
                 break;
             case ConpherenceUpdateActions::REMOVE_PERSON:
                 if (!$request->isContinueRequest()) {
                     // do nothing; we'll display a confirmation dialogue instead
                     break;
                 }
                 $person_phid = $request->getStr('remove_person');
                 if ($person_phid && $person_phid == $user->getPHID()) {
                     $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('-' => array($person_phid)));
                     $response_mode = 'go-home';
                 }
                 break;
             case ConpherenceUpdateActions::NOTIFICATIONS:
                 $notifications = $request->getStr('notifications');
                 $participant = $conpherence->getParticipantIfExists($user->getPHID());
                 if (!$participant) {
                     return id(new Aphront404Response());
                 }
                 $participant->setSettings(array('notifications' => $notifications));
                 $participant->save();
                 $result = pht('Updated notification settings to "%s".', ConpherenceSettings::getHumanString($notifications));
                 return id(new AphrontAjaxResponse())->setContent($result);
                 break;
             case ConpherenceUpdateActions::METADATA:
                 $top = $request->getInt('image_y');
                 $left = $request->getInt('image_x');
//.........这里部分代码省略.........
开发者ID:ryancford,项目名称:phabricator,代码行数:101,代码来源:ConpherenceUpdateController.php

示例14: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     if ($viewer->isLoggedIn()) {
         // Kick the user home if they are already logged in.
         return id(new AphrontRedirectResponse())->setURI('/');
     }
     if ($request->isAjax()) {
         return $this->processAjaxRequest();
     }
     if ($request->isConduit()) {
         return $this->processConduitRequest();
     }
     // If the user gets this far, they aren't logged in, so if they have a
     // user session token we can conclude that it's invalid: if it was valid,
     // they'd have been logged in above and never made it here. Try to clear
     // it and warn the user they may need to nuke their cookies.
     $session_token = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
     $did_clear = $request->getStr('cleared');
     if (strlen($session_token)) {
         $kind = PhabricatorAuthSessionEngine::getSessionKindFromToken($session_token);
         switch ($kind) {
             case PhabricatorAuthSessionEngine::KIND_ANONYMOUS:
                 // If this is an anonymous session. It's expected that they won't
                 // be logged in, so we can just continue.
                 break;
             default:
                 // The session cookie is invalid, so try to clear it.
                 $request->clearCookie(PhabricatorCookies::COOKIE_USERNAME);
                 $request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
                 // We've previously tried to clear the cookie but we ended up back
                 // here, so it didn't work. Hard fatal instead of trying again.
                 if ($did_clear) {
                     return $this->renderError(pht('Your login session is invalid, and clearing the session ' . 'cookie was unsuccessful. Try clearing your browser cookies.'));
                 }
                 $redirect_uri = $request->getRequestURI();
                 $redirect_uri->setQueryParam('cleared', 1);
                 return id(new AphrontRedirectResponse())->setURI($redirect_uri);
         }
     }
     // If we just cleared the session cookie and it worked, clean up after
     // ourselves by redirecting to get rid of the "cleared" parameter. The
     // the workflow will continue normally.
     if ($did_clear) {
         $redirect_uri = $request->getRequestURI();
         $redirect_uri->setQueryParam('cleared', null);
         return id(new AphrontRedirectResponse())->setURI($redirect_uri);
     }
     $providers = PhabricatorAuthProvider::getAllEnabledProviders();
     foreach ($providers as $key => $provider) {
         if (!$provider->shouldAllowLogin()) {
             unset($providers[$key]);
         }
     }
     if (!$providers) {
         if ($this->isFirstTimeSetup()) {
             // If this is a fresh install, let the user register their admin
             // account.
             return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/register/'));
         }
         return $this->renderError(pht('This Phabricator install is not configured with any enabled ' . 'authentication providers which can be used to log in. If you ' . 'have accidentally locked yourself out by disabling all providers, ' . 'you can use `%s` to recover access to an administrative account.', 'phabricator/bin/auth recover <username>'));
     }
     $next_uri = $request->getStr('next');
     if (!strlen($next_uri)) {
         if ($this->getDelegatingController()) {
             // Only set a next URI from the request path if this controller was
             // delegated to, which happens when a user tries to view a page which
             // requires them to login.
             // If this controller handled the request directly, we're on the main
             // login page, and never want to redirect the user back here after they
             // login.
             $next_uri = (string) $this->getRequest()->getRequestURI();
         }
     }
     if (!$request->isFormPost()) {
         if (strlen($next_uri)) {
             PhabricatorCookies::setNextURICookie($request, $next_uri);
         }
         PhabricatorCookies::setClientIDCookie($request);
     }
     $auto_response = $this->tryAutoLogin($providers);
     if ($auto_response) {
         return $auto_response;
     }
     $invite = $this->loadInvite();
     $not_buttons = array();
     $are_buttons = array();
     $providers = msort($providers, 'getLoginOrder');
     foreach ($providers as $provider) {
         if ($invite) {
             $form = $provider->buildInviteForm($this);
         } else {
             $form = $provider->buildLoginForm($this);
         }
         if ($provider->isLoginFormAButton()) {
             $are_buttons[] = $form;
         } else {
             $not_buttons[] = $form;
         }
     }
//.........这里部分代码省略.........
开发者ID:vinzent,项目名称:phabricator,代码行数:101,代码来源:PhabricatorAuthStartController.php

示例15: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $response = $this->loadDiffusionContext();
     if ($response) {
         return $response;
     }
     $viewer = $this->getViewer();
     $drequest = $this->getDiffusionRequest();
     if (!$request->isAjax()) {
         // This request came out of the dropdown menu, either "View Standalone"
         // or "View Raw File".
         $view = $request->getStr('view');
         if ($view == 'r') {
             $uri = $drequest->generateURI(array('action' => 'browse', 'params' => array('view' => 'raw')));
         } else {
             $uri = $drequest->generateURI(array('action' => 'change'));
         }
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $data = $this->callConduitWithDiffusionRequest('diffusion.diffquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath()));
     $drequest->updateSymbolicCommit($data['effectiveCommit']);
     $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
     $diff = DifferentialDiff::newEphemeralFromRawChanges($raw_changes);
     $changesets = $diff->getChangesets();
     $changeset = reset($changesets);
     if (!$changeset) {
         return new Aphront404Response();
     }
     $parser = new DifferentialChangesetParser();
     $parser->setUser($viewer);
     $parser->setChangeset($changeset);
     $parser->setRenderingReference($drequest->generateURI(array('action' => 'rendering-ref')));
     $parser->readParametersFromRequest($request);
     $coverage = $drequest->loadCoverage();
     if ($coverage) {
         $parser->setCoverage($coverage);
     }
     $commit = $drequest->loadCommit();
     $pquery = new DiffusionPathIDQuery(array($changeset->getFilename()));
     $ids = $pquery->loadPathIDs();
     $path_id = $ids[$changeset->getFilename()];
     $parser->setLeftSideCommentMapping($path_id, false);
     $parser->setRightSideCommentMapping($path_id, true);
     $parser->setCanMarkDone($commit->getAuthorPHID() && $viewer->getPHID() == $commit->getAuthorPHID());
     $parser->setObjectOwnerPHID($commit->getAuthorPHID());
     $parser->setWhitespaceMode(DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
     $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments($viewer, $commit->getPHID(), $path_id);
     if ($inlines) {
         foreach ($inlines as $inline) {
             $parser->parseInlineComment($inline);
         }
         $phids = mpull($inlines, 'getAuthorPHID');
         $handles = $this->loadViewerHandles($phids);
         $parser->setHandles($handles);
     }
     $engine = new PhabricatorMarkupEngine();
     $engine->setViewer($viewer);
     foreach ($inlines as $inline) {
         $engine->addObject($inline, PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
     }
     $engine->process();
     $parser->setMarkupEngine($engine);
     $spec = $request->getStr('range');
     list($range_s, $range_e, $mask) = DifferentialChangesetParser::parseRangeSpecification($spec);
     $parser->setRange($range_s, $range_e);
     $parser->setMask($mask);
     return id(new PhabricatorChangesetResponse())->setRenderedChangeset($parser->renderChangeset())->setUndoTemplates($parser->getRenderer()->renderUndoTemplates());
 }
开发者ID:truSense,项目名称:phabricator,代码行数:68,代码来源:DiffusionDiffController.php


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