本文整理汇总了PHP中PHUIInfoView::setSeverity方法的典型用法代码示例。如果您正苦于以下问题:PHP PHUIInfoView::setSeverity方法的具体用法?PHP PHUIInfoView::setSeverity怎么用?PHP PHUIInfoView::setSeverity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHUIInfoView
的用法示例。
在下文中一共展示了PHUIInfoView::setSeverity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildErrorView
protected function buildErrorView($error_message)
{
$error = new PHUIInfoView();
$error->setSeverity(PHUIInfoView::SEVERITY_ERROR);
$error->setTitle($error_message);
return $error;
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$task = id(new PhabricatorWorkerActiveTask())->load($id);
if (!$task) {
$tasks = id(new PhabricatorWorkerArchiveTaskQuery())->withIDs(array($id))->execute();
$task = reset($tasks);
}
$header = new PHUIHeaderView();
if (!$task) {
$title = pht('Task Does Not Exist');
$header->setHeader(pht('Task %d Missing', $id));
$error_view = new PHUIInfoView();
$error_view->setTitle(pht('No Such Task'));
$error_view->appendChild(phutil_tag('p', array(), pht('This task may have recently been garbage collected.')));
$error_view->setSeverity(PHUIInfoView::SEVERITY_NODATA);
$content = $error_view;
} else {
$title = pht('Task %d', $task->getID());
$header->setHeader(pht('Task %d: %s', $task->getID(), $task->getTaskClass()));
$properties = $this->buildPropertyListView($task);
$object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($properties);
$retry_head = id(new PHUIHeaderView())->setHeader(pht('Retries'));
$retry_info = $this->buildRetryListView($task);
$retry_box = id(new PHUIObjectBoxView())->setHeader($retry_head)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($retry_info);
$content = array($object_box, $retry_box);
}
$header->setHeaderIcon('fa-sort');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($content);
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例3: processImportRequest
private function processImportRequest($request)
{
$admin = $request->getUser();
$usernames = $request->getArr('usernames');
$emails = $request->getArr('email');
$names = $request->getArr('name');
$notice_view = new PHUIInfoView();
$notice_view->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$notice_view->setTitle(pht('Import Successful'));
$notice_view->setErrors(array(pht('Successfully imported users from LDAP')));
$list = new PHUIObjectItemListView();
$list->setNoDataString(pht('No users imported?'));
foreach ($usernames as $username) {
$user = new PhabricatorUser();
$user->setUsername($username);
$user->setRealname($names[$username]);
$email_obj = id(new PhabricatorUserEmail())->setAddress($emails[$username])->setIsVerified(1);
try {
id(new PhabricatorUserEditor())->setActor($admin)->createNewUser($user, $email_obj);
id(new PhabricatorExternalAccount())->setUserPHID($user->getPHID())->setAccountType('ldap')->setAccountDomain('self')->setAccountID($username)->save();
$header = pht('Successfully added %s', $username);
$attribute = null;
$color = 'fa-check green';
} catch (Exception $ex) {
$header = pht('Failed to add %s', $username);
$attribute = $ex->getMessage();
$color = 'fa-times red';
}
$item = id(new PHUIObjectItemView())->setHeader($header)->addAttribute($attribute)->setStatusIcon($color);
$list->addItem($item);
}
return array($notice_view, $list);
}
示例4: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$task = id(new PhabricatorWorkerActiveTask())->load($this->id);
if (!$task) {
$tasks = id(new PhabricatorWorkerArchiveTaskQuery())->withIDs(array($this->id))->execute();
$task = reset($tasks);
}
if (!$task) {
$title = pht('Task Does Not Exist');
$error_view = new PHUIInfoView();
$error_view->setTitle(pht('No Such Task'));
$error_view->appendChild(phutil_tag('p', array(), pht('This task may have recently been garbage collected.')));
$error_view->setSeverity(PHUIInfoView::SEVERITY_NODATA);
$content = $error_view;
} else {
$title = pht('Task %d', $task->getID());
$header = id(new PHUIHeaderView())->setHeader(pht('Task %d (%s)', $task->getID(), $task->getTaskClass()));
$properties = $this->buildPropertyListView($task);
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$retry_head = id(new PHUIHeaderView())->setHeader(pht('Retries'));
$retry_info = $this->buildRetryListView($task);
$retry_box = id(new PHUIObjectBoxView())->setHeader($retry_head)->addPropertyList($retry_info);
$content = array($object_box, $retry_box);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
return $this->buildApplicationPage(array($crumbs, $content), array('title' => $title));
}
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$xscript = id(new HeraldTranscriptQuery())->setViewer($viewer)->withIDs(array($this->id))->executeOne();
if (!$xscript) {
return new Aphront404Response();
}
require_celerity_resource('herald-test-css');
$nav = $this->buildSideNav();
$object_xscript = $xscript->getObjectTranscript();
if (!$object_xscript) {
$notice = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Old Transcript'))->appendChild(phutil_tag('p', array(), pht('Details of this transcript have been garbage collected.')));
$nav->appendChild($notice);
} else {
$map = HeraldAdapter::getEnabledAdapterMap($viewer);
$object_type = $object_xscript->getType();
if (empty($map[$object_type])) {
// TODO: We should filter these out in the Query, but we have to load
// the objectTranscript right now, which is potentially enormous. We
// should denormalize the object type, or move the data into a separate
// table, and then filter this earlier (and thus raise a better error).
// For now, just block access so we don't violate policies.
throw new Exception(pht('This transcript has an invalid or inaccessible adapter.'));
}
$this->adapter = HeraldAdapter::getAdapterForContentType($object_type);
$filter = $this->getFilterPHIDs();
$this->filterTranscript($xscript, $filter);
$phids = array_merge($filter, $this->getTranscriptPHIDs($xscript));
$phids = array_unique($phids);
$phids = array_filter($phids);
$handles = $this->loadViewerHandles($phids);
$this->handles = $handles;
if ($xscript->getDryRun()) {
$notice = new PHUIInfoView();
$notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$notice->setTitle(pht('Dry Run'));
$notice->appendChild(pht('This was a dry run to test Herald rules, ' . 'no actions were executed.'));
$nav->appendChild($notice);
}
$warning_panel = $this->buildWarningPanel($xscript);
$nav->appendChild($warning_panel);
$apply_xscript_panel = $this->buildApplyTranscriptPanel($xscript);
$nav->appendChild($apply_xscript_panel);
$action_xscript_panel = $this->buildActionTranscriptPanel($xscript);
$nav->appendChild($action_xscript_panel);
$object_xscript_panel = $this->buildObjectTranscriptPanel($xscript);
$nav->appendChild($object_xscript_panel);
}
$crumbs = id($this->buildApplicationCrumbs())->addTextCrumb(pht('Transcripts'), $this->getApplicationURI('/transcript/'))->addTextCrumb($xscript->getID());
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage($nav, array('title' => pht('Transcript')));
}
示例6: render
public function render()
{
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit = $drequest->getCommit();
if ($commit) {
$commit = $repository->formatCommitName($commit);
} else {
$commit = 'HEAD';
}
$reason = $this->browseResultSet->getReasonForEmptyResultSet();
switch ($reason) {
case DiffusionBrowseResultSet::REASON_IS_NONEXISTENT:
$title = pht('Path Does Not Exist');
// TODO: Under git, this error message should be more specific. It
// may exist on some other branch.
$body = pht('This path does not exist anywhere.');
$severity = PHUIInfoView::SEVERITY_ERROR;
break;
case DiffusionBrowseResultSet::REASON_IS_EMPTY:
$title = pht('Empty Directory');
$body = pht('This path was an empty directory at %s.', $commit);
$severity = PHUIInfoView::SEVERITY_NOTICE;
break;
case DiffusionBrowseResultSet::REASON_IS_DELETED:
$deleted = $this->browseResultSet->getDeletedAtCommit();
$existed = $this->browseResultSet->getExistedAtCommit();
$existed_text = $repository->formatCommitName($existed);
$existed_href = $drequest->generateURI(array('action' => 'browse', 'path' => $drequest->getPath(), 'commit' => $existed, 'params' => array('view' => $this->view)));
$existed_link = phutil_tag('a', array('href' => $existed_href), $existed_text);
$title = pht('Path Was Deleted');
$body = pht('This path does not exist at %s. It was deleted in %s and last ' . 'existed at %s.', $commit, self::linkCommit($drequest->getRepository(), $deleted), $existed_link);
$severity = PHUIInfoView::SEVERITY_WARNING;
break;
case DiffusionBrowseResultSet::REASON_IS_UNTRACKED_PARENT:
$subdir = $drequest->getRepository()->getDetail('svn-subpath');
$title = pht('Directory Not Tracked');
$body = pht("This repository is configured to track only one subdirectory " . "of the entire repository ('%s'), but you aren't looking at " . "something in that subdirectory, so no information is available.", $subdir);
$severity = PHUIInfoView::SEVERITY_WARNING;
break;
default:
throw new Exception(pht('Unknown failure reason: %s', $reason));
}
$error_view = new PHUIInfoView();
$error_view->setSeverity($severity);
$error_view->setTitle($title);
$error_view->appendChild(phutil_tag('p', array(), $body));
return $error_view->render();
}
示例7: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $this->getUser();
$viewer = $request->getUser();
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($viewer, $request, '/settings/');
if ($request->isFormPost()) {
if (!$request->isDialogFormPost()) {
$dialog = new AphrontDialogView();
$dialog->setUser($viewer);
$dialog->setTitle(pht('Really regenerate session?'));
$dialog->setSubmitURI($this->getPanelURI());
$dialog->addSubmitButton(pht('Regenerate'));
$dialog->addCancelbutton($this->getPanelURI());
$dialog->appendChild(phutil_tag('p', array(), pht('Really destroy the old certificate? Any established ' . 'sessions will be terminated.')));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$sessions = id(new PhabricatorAuthSessionQuery())->setViewer($user)->withIdentityPHIDs(array($user->getPHID()))->withSessionTypes(array(PhabricatorAuthSession::TYPE_CONDUIT))->execute();
foreach ($sessions as $session) {
$session->delete();
}
// This implicitly regenerates the certificate.
$user->setConduitCertificate(null);
$user->save();
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?regenerated=true'));
}
if ($request->getStr('regenerated')) {
$notice = new PHUIInfoView();
$notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$notice->setTitle(pht('Certificate Regenerated'));
$notice->appendChild(phutil_tag('p', array(), pht('Your old certificate has been destroyed and you have been issued ' . 'a new certificate. Sessions established under the old certificate ' . 'are no longer valid.')));
$notice = $notice->render();
} else {
$notice = null;
}
Javelin::initBehavior('select-on-click');
$cert_form = new AphrontFormView();
$cert_form->setUser($viewer)->appendChild(phutil_tag('p', array('class' => 'aphront-form-instructions'), pht('This certificate allows you to authenticate over Conduit, ' . 'the Phabricator API. Normally, you just run %s to install it.', phutil_tag('tt', array(), 'arc install-certificate'))))->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Certificate'))->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT)->setReadonly(true)->setSigil('select-on-click')->setValue($user->getConduitCertificate()));
$cert_form = id(new PHUIObjectBoxView())->setHeaderText(pht('Arcanist Certificate'))->setForm($cert_form);
$regen_instruction = pht('You can regenerate this certificate, which ' . 'will invalidate the old certificate and create a new one.');
$regen_form = new AphrontFormView();
$regen_form->setUser($viewer)->setAction($this->getPanelURI())->setWorkflow(true)->appendChild(phutil_tag('p', array('class' => 'aphront-form-instructions'), $regen_instruction))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Regenerate Certificate')));
$regen_form = id(new PHUIObjectBoxView())->setHeaderText(pht('Regenerate Certificate'))->setForm($regen_form);
return array($notice, $cert_form, $regen_form);
}
示例8: renderExample
public function renderExample()
{
$request = $this->getRequest();
$user = $request->getUser();
$sevs = array(PHUIInfoView::SEVERITY_ERROR => pht('Error'), PHUIInfoView::SEVERITY_WARNING => pht('Warning'), PHUIInfoView::SEVERITY_NODATA => pht('No Data'), PHUIInfoView::SEVERITY_NOTICE => pht('Notice'), PHUIInfoView::SEVERITY_SUCCESS => pht('Success'));
$button = id(new PHUIButtonView())->setTag('a')->setText(pht('Resolve Issue'))->setHref('#');
$views = array();
// Only Title
foreach ($sevs as $sev => $title) {
$view = new PHUIInfoView();
$view->setSeverity($sev);
$view->setTitle($title);
$views[] = $view;
}
$views[] = phutil_tag('br', array(), null);
// Only Body
foreach ($sevs as $sev => $title) {
$view = new PHUIInfoView();
$view->setSeverity($sev);
$view->appendChild(pht('Several issues were encountered.'));
$view->addButton($button);
$views[] = $view;
}
$views[] = phutil_tag('br', array(), null);
// Only Errors
foreach ($sevs as $sev => $title) {
$view = new PHUIInfoView();
$view->setSeverity($sev);
$view->setErrors(array(pht('Overcooked.'), pht('Too much salt.'), pht('Full of sand.')));
$views[] = $view;
}
$views[] = phutil_tag('br', array(), null);
// All
foreach ($sevs as $sev => $title) {
$view = new PHUIInfoView();
$view->setSeverity($sev);
$view->setTitle($title);
$view->appendChild(pht('Several issues were encountered.'));
$view->setErrors(array(pht('Overcooked.'), pht('Too much salt.'), pht('Full of sand.')));
$views[] = $view;
}
return $views;
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$email = $viewer->loadPrimaryEmail();
if ($viewer->getIsEmailVerified()) {
return id(new AphrontRedirectResponse())->setURI('/');
}
$email_address = $email->getAddress();
$sent = null;
if ($request->isFormPost()) {
$email->sendVerificationEmail($viewer);
$sent = new PHUIInfoView();
$sent->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$sent->setTitle(pht('Email Sent'));
$sent->appendChild(pht('Another verification email was sent to %s.', phutil_tag('strong', array(), $email_address)));
}
$must_verify = pht('You must verify your email address to login. You should have a ' . 'new email message from Phabricator with verification instructions ' . 'in your inbox (%s).', phutil_tag('strong', array(), $email_address));
$send_again = pht('If you did not receive an email, you can click the button below ' . 'to try sending another one.');
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Check Your Email'))->appendParagraph($must_verify)->appendParagraph($send_again)->addSubmitButton(pht('Send Another Email'));
return $this->buildApplicationPage(array($sent, $dialog), array('title' => pht('Must Verify Email')));
}
示例10: buildMergesTable
private function buildMergesTable(PhabricatorRepositoryCommit $commit)
{
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// These aren't supported under SVN.
return null;
}
$limit = 50;
$merges = $this->callConduitWithDiffusionRequest('diffusion.mergedcommitsquery', array('commit' => $drequest->getCommit(), 'limit' => $limit + 1));
if (!$merges) {
return null;
}
$merges = DiffusionPathChange::newFromConduit($merges);
$caption = null;
if (count($merges) > $limit) {
$merges = array_slice($merges, 0, $limit);
$caption = new PHUIInfoView();
$caption->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$caption->appendChild(pht('This commit merges a very large number of changes. ' . 'Only the first %s are shown.', new PhutilNumber($limit)));
}
$history_table = new DiffusionHistoryTableView();
$history_table->setUser($this->getRequest()->getUser());
$history_table->setDiffusionRequest($drequest);
$history_table->setHistory($merges);
$history_table->loadRevisions();
$phids = $history_table->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids);
$history_table->setHandles($handles);
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Merged Changes'));
$panel->setTable($history_table);
if ($caption) {
$panel->setInfoView($caption);
}
return $panel;
}
示例11: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn();
$revision = id(new DifferentialRevisionQuery())->withIDs(array($this->revisionID))->setViewer($request->getUser())->needRelationships(true)->needReviewerStatus(true)->needReviewerAuthority(true)->executeOne();
if (!$revision) {
return new Aphront404Response();
}
$diffs = id(new DifferentialDiffQuery())->setViewer($request->getUser())->withRevisionIDs(array($this->revisionID))->execute();
$diffs = array_reverse($diffs, $preserve_keys = true);
if (!$diffs) {
throw new Exception(pht('This revision has no diffs. Something has gone quite wrong.'));
}
$revision->attachActiveDiff(last($diffs));
$diff_vs = $request->getInt('vs');
$target_id = $request->getInt('id');
$target = idx($diffs, $target_id, end($diffs));
$target_manual = $target;
if (!$target_id) {
foreach ($diffs as $diff) {
if ($diff->getCreationMethod() != 'commit') {
$target_manual = $diff;
}
}
}
if (empty($diffs[$diff_vs])) {
$diff_vs = null;
}
$repository = null;
$repository_phid = $target->getRepositoryPHID();
if ($repository_phid) {
if ($repository_phid == $revision->getRepositoryPHID()) {
$repository = $revision->getRepository();
} else {
$repository = id(new PhabricatorRepositoryQuery())->setViewer($user)->withPHIDs(array($repository_phid))->executeOne();
}
}
list($changesets, $vs_map, $vs_changesets, $rendering_references) = $this->loadChangesetsAndVsMap($target, idx($diffs, $diff_vs), $repository);
if ($request->getExists('download')) {
return $this->buildRawDiffResponse($revision, $changesets, $vs_changesets, $vs_map, $repository);
}
$map = $vs_map;
if (!$map) {
$map = array_fill_keys(array_keys($changesets), 0);
}
$old_ids = array();
$new_ids = array();
foreach ($map as $id => $vs) {
if ($vs <= 0) {
$old_ids[] = $id;
$new_ids[] = $id;
} else {
$new_ids[] = $id;
$new_ids[] = $vs;
}
}
$props = id(new DifferentialDiffProperty())->loadAllWhere('diffID = %d', $target_manual->getID());
$props = mpull($props, 'getData', 'getName');
$object_phids = array_merge($revision->getReviewers(), $revision->getCCPHIDs(), $revision->loadCommitPHIDs(), array($revision->getAuthorPHID(), $user->getPHID()));
foreach ($revision->getAttached() as $type => $phids) {
foreach ($phids as $phid => $info) {
$object_phids[] = $phid;
}
}
$field_list = PhabricatorCustomField::getObjectFields($revision, PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($user);
$field_list->readFieldsFromStorage($revision);
$warning_handle_map = array();
foreach ($field_list->getFields() as $key => $field) {
$req = $field->getRequiredHandlePHIDsForRevisionHeaderWarnings();
foreach ($req as $phid) {
$warning_handle_map[$key][] = $phid;
$object_phids[] = $phid;
}
}
$handles = $this->loadViewerHandles($object_phids);
$request_uri = $request->getRequestURI();
$limit = 100;
$large = $request->getStr('large');
if (count($changesets) > $limit && !$large) {
$count = count($changesets);
$warning = new PHUIInfoView();
$warning->setTitle(pht('Very Large Diff'));
$warning->setSeverity(PHUIInfoView::SEVERITY_WARNING);
$warning->appendChild(hsprintf('%s <strong>%s</strong>', pht('This diff is very large and affects %s files. ' . 'You may load each file individually or ', new PhutilNumber($count)), phutil_tag('a', array('class' => 'button grey', 'href' => $request_uri->alter('large', 'true')->setFragment('toc')), pht('Show All Files Inline'))));
$warning = $warning->render();
$old = array_select_keys($changesets, $old_ids);
$new = array_select_keys($changesets, $new_ids);
$query = id(new DifferentialInlineCommentQuery())->setViewer($user)->needHidden(true)->withRevisionPHIDs(array($revision->getPHID()));
$inlines = $query->execute();
$inlines = $query->adjustInlinesForChangesets($inlines, $old, $new, $revision);
$visible_changesets = array();
foreach ($inlines as $inline) {
$changeset_id = $inline->getChangesetID();
if (isset($changesets[$changeset_id])) {
$visible_changesets[$changeset_id] = $changesets[$changeset_id];
}
}
} else {
//.........这里部分代码省略.........
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$current_version = null;
if ($id) {
$document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$document) {
return new Aphront404Response();
}
$current_version = $document->getContent()->getVersion();
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere('documentID = %d AND version = %d', $document->getID(), $revert);
if (!$content) {
return new Aphront404Response();
}
} else {
$content = $document->getContent();
}
} else {
$slug = $request->getStr('slug');
$slug = PhabricatorSlug::normalize($slug);
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withSlugs(array($slug))->needContent(true)->executeOne();
if ($document) {
$content = $document->getContent();
$current_version = $content->getVersion();
} else {
$document = PhrictionDocument::initializeNewDocument($viewer, $slug);
$content = $document->getContent();
}
}
if ($request->getBool('nodraft')) {
$draft = null;
$draft_key = null;
} else {
if ($document->getPHID()) {
$draft_key = $document->getPHID() . ':' . $content->getVersion();
} else {
$draft_key = 'phriction:' . $content->getSlug();
}
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $viewer->getPHID(), $draft_key);
}
if ($draft && strlen($draft->getDraft()) && $draft->getDraft() != $content->getContent()) {
$content_text = $draft->getDraft();
$discard = phutil_tag('a', array('href' => $request->getRequestURI()->alter('nodraft', true)), pht('discard this draft'));
$draft_note = new PHUIInfoView();
$draft_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$draft_note->setTitle(pht('Recovered Draft'));
$draft_note->appendChild(hsprintf('<p>%s</p>', pht('Showing a saved draft of your edits, you can %s.', $discard)));
} else {
$content_text = $content->getContent();
$draft_note = null;
}
require_celerity_resource('phriction-document-css');
$e_title = true;
$e_content = true;
$validation_exception = null;
$notes = null;
$title = $content->getTitle();
$overwrite = false;
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID($document->getPHID());
if ($request->isFormPost()) {
$title = $request->getStr('title');
$content_text = $request->getStr('content');
$notes = $request->getStr('description');
$current_version = $request->getInt('contentVersion');
$v_view = $request->getStr('viewPolicy');
$v_edit = $request->getStr('editPolicy');
$v_cc = $request->getArr('cc');
$xactions = array();
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_TITLE)->setNewValue($title);
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_CONTENT)->setNewValue($content_text);
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('=' => $v_cc));
$editor = id(new PhrictionTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setDescription($notes)->setProcessContentVersionError(!$request->getBool('overwrite'))->setContentVersion($current_version);
try {
$editor->applyTransactions($document, $xactions);
if ($draft) {
$draft->delete();
}
$uri = PhrictionDocument::getSlugURI($document->getSlug());
return id(new AphrontRedirectResponse())->setURI($uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_title = nonempty($ex->getShortMessage(PhrictionTransaction::TYPE_TITLE), true);
$e_content = nonempty($ex->getShortMessage(PhrictionTransaction::TYPE_CONTENT), true);
// if we're not supposed to process the content version error, then
// overwrite that content...!
if (!$editor->getProcessContentVersionError()) {
$overwrite = true;
}
$document->setViewPolicy($v_view);
$document->setEditPolicy($v_edit);
}
}
//.........这里部分代码省略.........
示例13: renderMiniPanel
private function renderMiniPanel($title, $body)
{
$panel = new PHUIInfoView();
$panel->setSeverity(PHUIInfoView::SEVERITY_NODATA);
$panel->appendChild(phutil_tag('p', array(), array(phutil_tag('strong', array(), $title . ': '), $body)));
$this->minipanels[] = $panel;
}
示例14: buildMergesTable
private function buildMergesTable(PhabricatorRepositoryCommit $commit)
{
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$merges = $this->getCommitMerges();
if (!$merges) {
return null;
}
$limit = $this->getMergeDisplayLimit();
$caption = null;
if (count($merges) > $limit) {
$merges = array_slice($merges, 0, $limit);
$caption = new PHUIInfoView();
$caption->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$caption->appendChild(pht('This commit merges a very large number of changes. ' . 'Only the first %s are shown.', new PhutilNumber($limit)));
}
$history_table = id(new DiffusionHistoryTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setHistory($merges);
$history_table->loadRevisions();
$panel = new PHUIObjectBoxView();
$panel->setHeaderText(pht('Merged Changes'));
$panel->setTable($history_table);
if ($caption) {
$panel->setInfoView($caption);
}
return $panel;
}
示例15: browseFile
private function browseFile()
{
$viewer = $this->getViewer();
$request = $this->getRequest();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$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());
$byte_limit = null;
if ($view !== 'raw') {
$byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
$time_limit = 10;
$params += array('timeout' => $time_limit, 'byteLimit' => $byte_limit);
}
$response = $this->callConduitWithDiffusionRequest('diffusion.filecontentquery', $params);
$hit_byte_limit = $response['tooHuge'];
$hit_time_limit = $response['tooSlow'];
$file_phid = $response['filePHID'];
if ($hit_byte_limit) {
$corpus = $this->buildErrorCorpus(pht('This file is larger than %s byte(s), and too large to display ' . 'in the web UI.', phutil_format_bytes($byte_limit)));
} else {
if ($hit_time_limit) {
$corpus = $this->buildErrorCorpus(pht('This file took too long to load from the repository (more than ' . '%s second(s)).', new PhutilNumber($time_limit)));
} else {
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($file_phid))->executeOne();
if (!$file) {
throw new Exception(pht('Failed to load content file!'));
}
if ($view === 'raw') {
return $file->getRedirectResponse();
}
$data = $file->loadFileData();
if (ArcanistDiffUtils::isHeuristicBinaryFile($data)) {
$file_uri = $file->getBestURI();
if ($file->isViewableImage()) {
$corpus = $this->buildImageCorpus($file_uri);
} else {
$corpus = $this->buildBinaryCorpus($file_uri, $data);
}
} else {
$this->loadLintMessages();
$this->coverage = $drequest->loadCoverage();
// Build the content of the file.
$corpus = $this->buildCorpus($show_blame, $show_color, $data, $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;
//.........这里部分代码省略.........