本文整理汇总了PHP中phutil_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_tag函数的具体用法?PHP phutil_tag怎么用?PHP phutil_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderModuleStatus
public function renderModuleStatus(AphrontRequest $request)
{
$viewer = $request->getViewer();
$collectors = PhabricatorGarbageCollector::getAllCollectors();
$collectors = msort($collectors, 'getCollectorConstant');
$rows = array();
$rowc = array();
foreach ($collectors as $key => $collector) {
$class = null;
if ($collector->hasAutomaticPolicy()) {
$policy_view = phutil_tag('em', array(), pht('Automatic'));
} else {
$policy = $collector->getRetentionPolicy();
if ($policy === null) {
$policy_view = pht('Indefinite');
} else {
$days = ceil($policy / phutil_units('1 day in seconds'));
$policy_view = pht('%s Day(s)', new PhutilNumber($days));
}
$default = $collector->getDefaultRetentionPolicy();
if ($policy !== $default) {
$class = 'highlighted';
$policy_view = phutil_tag('strong', array(), $policy_view);
}
}
$rowc[] = $class;
$rows[] = array($collector->getCollectorConstant(), $collector->getCollectorName(), $policy_view);
}
$table = id(new AphrontTableView($rows))->setRowClasses($rowc)->setHeaders(array(pht('Constant'), pht('Name'), pht('Retention Policy')))->setColumnClasses(array(null, 'pri wide', null));
$header = id(new PHUIHeaderView())->setHeader(pht('Garbage Collectors'))->setSubheader(pht('Collectors with custom policies are highlighted. Use ' . '%s to change retention policies.', phutil_tag('tt', array(), 'bin/garbage set-policy')));
return id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
// If the user already has a full session, just kick them out of here.
$has_partial_session = $viewer->hasSession() && $viewer->getSession()->getIsPartial();
if (!$has_partial_session) {
return id(new AphrontRedirectResponse())->setURI('/');
}
$engine = new PhabricatorAuthSessionEngine();
// If this cookie is set, the user is headed into a high security area
// after login (normally because of a password reset) so if they are
// able to pass the checkpoint we just want to put their account directly
// into high security mode, rather than prompt them again for the same
// set of credentials.
$jump_into_hisec = $request->getCookie(PhabricatorCookies::COOKIE_HISEC);
try {
$token = $engine->requireHighSecuritySession($viewer, $request, '/logout/', $jump_into_hisec);
} catch (PhabricatorAuthHighSecurityRequiredException $ex) {
$form = id(new PhabricatorAuthSessionEngine())->renderHighSecurityForm($ex->getFactors(), $ex->getFactorValidationResults(), $viewer, $request);
return $this->newDialog()->setTitle(pht('Provide Multi-Factor Credentials'))->setShortTitle(pht('Multi-Factor Login'))->setWidth(AphrontDialogView::WIDTH_FORM)->addHiddenInput(AphrontRequest::TYPE_HISEC, true)->appendParagraph(pht('Welcome, %s. To complete the login process, provide your ' . 'multi-factor credentials.', phutil_tag('strong', array(), $viewer->getUsername())))->appendChild($form->buildLayoutView())->setSubmitURI($request->getPath())->addCancelButton($ex->getCancelURI())->addSubmitButton(pht('Continue'));
}
// Upgrade the partial session to a full session.
$engine->upgradePartialSession($viewer);
// TODO: It might be nice to add options like "bind this session to my IP"
// here, even for accounts without multi-factor auth attached to them.
$next = PhabricatorCookies::getNextURICookie($request);
$request->clearCookie(PhabricatorCookies::COOKIE_NEXTURI);
$request->clearCookie(PhabricatorCookies::COOKIE_HISEC);
if (!PhabricatorEnv::isValidLocalURIForLink($next)) {
$next = '/';
}
return id(new AphrontRedirectResponse())->setURI($next);
}
示例3: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$configs = id(new PhabricatorAuthProviderConfigQuery())->setViewer($viewer)->execute();
$list = new PHUIObjectItemListView();
$can_manage = $this->hasApplicationCapability(AuthManageProvidersCapability::CAPABILITY);
foreach ($configs as $config) {
$item = new PHUIObjectItemView();
$id = $config->getID();
$edit_uri = $this->getApplicationURI('config/edit/' . $id . '/');
$enable_uri = $this->getApplicationURI('config/enable/' . $id . '/');
$disable_uri = $this->getApplicationURI('config/disable/' . $id . '/');
$provider = $config->getProvider();
if ($provider) {
$name = $provider->getProviderName();
} else {
$name = $config->getProviderType() . ' (' . $config->getProviderClass() . ')';
}
$item->setHeader($name);
if ($provider) {
$item->setHref($edit_uri);
} else {
$item->addAttribute(pht('Provider Implementation Missing!'));
}
$domain = null;
if ($provider) {
$domain = $provider->getProviderDomain();
if ($domain !== 'self') {
$item->addAttribute($domain);
}
}
if ($config->getShouldAllowRegistration()) {
$item->addAttribute(pht('Allows Registration'));
} else {
$item->addAttribute(pht('Does Not Allow Registration'));
}
if ($config->getIsEnabled()) {
$item->setStatusIcon('fa-check-circle green');
$item->addAction(id(new PHUIListItemView())->setIcon('fa-times')->setHref($disable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
} else {
$item->setStatusIcon('fa-ban red');
$item->addIcon('fa-ban grey', pht('Disabled'));
$item->addAction(id(new PHUIListItemView())->setIcon('fa-plus')->setHref($enable_uri)->setDisabled(!$can_manage)->addSigil('workflow'));
}
$list->addItem($item);
}
$list->setNoDataString(pht('%s You have not added authentication providers yet. Use "%s" to add ' . 'a provider, which will let users register new Phabricator accounts ' . 'and log in.', phutil_tag('strong', array(), pht('No Providers Configured:')), phutil_tag('a', array('href' => $this->getApplicationURI('config/new/')), pht('Add Authentication Provider'))));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Auth Providers'));
$crumbs->setBorder(true);
$guidance_context = new PhabricatorAuthProvidersGuidanceContext();
$guidance = id(new PhabricatorGuidanceEngine())->setViewer($viewer)->setGuidanceContext($guidance_context)->newInfoView();
$button = id(new PHUIButtonView())->setTag('a')->setColor(PHUIButtonView::SIMPLE)->setHref($this->getApplicationURI('config/new/'))->setIcon('fa-plus')->setDisabled(!$can_manage)->setText(pht('Add Provider'));
$list->setFlush(true);
$list = id(new PHUIObjectBoxView())->setHeaderText(pht('Providers'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($list);
$title = pht('Auth Providers');
$header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-key')->addActionLink($button);
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($guidance, $list));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例4: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$viewer = $request->getUser();
$this->requireApplicationCapability(DiffusionCreateRepositoriesCapability::CAPABILITY);
if ($request->isFormPost()) {
if ($request->getStr('type')) {
switch ($request->getStr('type')) {
case 'create':
$uri = $this->getApplicationURI('create/');
break;
case 'import':
default:
$uri = $this->getApplicationURI('import/');
break;
}
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Repository Hosting');
$doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Diffusion User Guide: Repository Hosting'));
$form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormRadioButtonControl())->setName('type')->addButton('create', pht('Create a New Hosted Repository'), array(pht('Create a new, empty repository which Phabricator will host. ' . 'For instructions on configuring repository hosting, see %s.', $doc_link)))->addButton('import', pht('Import an Existing External Repository'), pht("Import a repository hosted somewhere else, like GitHub, " . "Bitbucket, or your organization's existing servers. " . "Phabricator will read changes from the repository but will " . "not host or manage it. The authoritative master version of " . "the repository will stay where it is now.")))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($this->getApplicationURI()));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('New Repository'));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Create or Import Repository'))->setForm($form);
return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => pht('New Repository')));
}
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($this->id))->needMembers(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$project) {
return new Aphront404Response();
}
$member_phids = $project->getMemberPHIDs();
$remove_phid = $request->getStr('phid');
if (!in_array($remove_phid, $member_phids)) {
return new Aphront404Response();
}
$members_uri = $this->getApplicationURI('members/' . $project->getID() . '/');
if ($request->isFormPost()) {
$member_spec = array();
$member_spec['-'] = array($remove_phid => $remove_phid);
$type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue($member_spec);
$editor = id(new PhabricatorProjectTransactionEditor($project))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($members_uri);
}
$handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($remove_phid))->executeOne();
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Really Remove Member?'))->appendParagraph(pht('Really remove %s from the project %s?', phutil_tag('strong', array(), $handle->getName()), phutil_tag('strong', array(), $project->getName())))->addCancelButton($members_uri)->addSubmitButton(pht('Remove Project Member'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例6: validateCustomDomain
/**
* Makes sure a given custom blog uri is properly configured in DNS
* to point at this Phabricator instance. If there is an error in
* the configuration, return a string describing the error and how
* to fix it. If there is no error, return an empty string.
*
* @return string
*/
public function validateCustomDomain($custom_domain)
{
$example_domain = 'blog.example.com';
$label = pht('Invalid');
// note this "uri" should be pretty busted given the desired input
// so just use it to test if there's a protocol specified
$uri = new PhutilURI($custom_domain);
if ($uri->getProtocol()) {
return array($label, pht('The custom domain should not include a protocol. Just provide ' . 'the bare domain name (for example, "%s").', $example_domain));
}
if ($uri->getPort()) {
return array($label, pht('The custom domain should not include a port number. Just provide ' . 'the bare domain name (for example, "%s").', $example_domain));
}
if (strpos($custom_domain, '/') !== false) {
return array($label, pht('The custom domain should not specify a path (hosting a Phame ' . 'blog at a path is currently not supported). Instead, just provide ' . 'the bare domain name (for example, "%s").', $example_domain));
}
if (strpos($custom_domain, '.') === false) {
return array($label, pht('The custom domain should contain at least one dot (.) because ' . 'some browsers fail to set cookies on domains without a dot. ' . 'Instead, use a normal looking domain name like "%s".', $example_domain));
}
if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) {
$href = PhabricatorEnv::getProductionURI('/config/edit/policy.allow-public/');
return array(pht('Fix Configuration'), pht('For custom domains to work, this Phabricator instance must be ' . 'configured to allow the public access policy. Configure this ' . 'setting %s, or ask an administrator to configure this setting. ' . 'The domain can be specified later once this setting has been ' . 'changed.', phutil_tag('a', array('href' => $href), pht('here'))));
}
return null;
}
示例7: buildNav
public function buildNav()
{
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/'));
$applications = id(new PhabricatorApplicationQuery())->setViewer($user)->withInstalled(true)->withUnlisted(false)->withLaunchable(true)->execute();
$pinned = $user->loadPreferences()->getPinnedApplications($applications, $user);
// Force "Applications" to appear at the bottom.
$meta_app = 'PhabricatorApplicationsApplication';
$pinned = array_fuse($pinned);
unset($pinned[$meta_app]);
$pinned[$meta_app] = $meta_app;
$applications[$meta_app] = PhabricatorApplication::getByClass($meta_app);
$tiles = array();
$home_app = new PhabricatorHomeApplication();
$tiles[] = id(new PhabricatorApplicationLaunchView())->setApplication($home_app)->setApplicationStatus($home_app->loadStatus($user))->addClass('phabricator-application-launch-phone-only')->setUser($user);
foreach ($pinned as $pinned_application) {
if (empty($applications[$pinned_application])) {
continue;
}
$application = $applications[$pinned_application];
$tile = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus($application->loadStatus($user))->setUser($user);
$tiles[] = $tile;
}
$nav->addCustomBlock(phutil_tag('div', array('class' => 'application-tile-group'), $tiles));
$nav->addFilter('', pht('Customize Applications...'), '/settings/panel/home/');
$nav->addClass('phabricator-side-menu-home');
$nav->selectFilter(null);
return $nav;
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$admin = $request->getUser();
$user = id(new PhabricatorPeopleQuery())->setViewer($admin)->withIDs(array($this->id))->executeOne();
if (!$user) {
return new Aphront404Response();
}
$profile_uri = '/p/' . $user->getUsername() . '/';
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($admin, $request, $profile_uri);
if ($user->getPHID() == $admin->getPHID()) {
return $this->newDialog()->setTitle(pht('Your Way is Blocked'))->appendParagraph(pht('After a time, your efforts fail. You can not adjust your own ' . 'status as an administrator.'))->addCancelButton($profile_uri, pht('Accept Fate'));
}
if ($request->isFormPost()) {
id(new PhabricatorUserEditor())->setActor($admin)->makeAdminUser($user, !$user->getIsAdmin());
return id(new AphrontRedirectResponse())->setURI($profile_uri);
}
if ($user->getIsAdmin()) {
$title = pht('Remove as Administrator?');
$short = pht('Remove Administrator');
$body = pht('Remove %s as an administrator? They will no longer be able to ' . 'perform administrative functions on this Phabricator install.', phutil_tag('strong', array(), $user->getUsername()));
$submit = pht('Remove Administrator');
} else {
$title = pht('Make Administrator?');
$short = pht('Make Administrator');
$body = pht('Empower %s as an administrator? They will be able to create users, ' . 'approve users, make and remove administrators, delete accounts, and ' . 'perform other administrative functions on this Phabricator install.', phutil_tag('strong', array(), $user->getUsername()));
$submit = pht('Make Administrator');
}
return $this->newDialog()->setTitle($title)->setShortTitle($short)->appendParagraph($body)->addCancelButton($profile_uri)->addSubmitButton($submit);
}
示例9: markupText
public function markupText($text, $children)
{
$matches = array();
preg_match($this->getRegEx(), $text, $matches);
if (idx($matches, 'showword')) {
$word = $matches['showword'];
$show = true;
} else {
$word = $matches['hideword'];
$show = false;
}
$class_suffix = phutil_utf8_strtolower($word);
// This is the "(IMPORTANT)" or "NOTE:" part.
$word_part = rtrim(substr($text, 0, strlen($matches[0])));
// This is the actual text.
$text_part = substr($text, strlen($matches[0]));
$text_part = $this->applyRules(rtrim($text_part));
$text_mode = $this->getEngine()->isTextMode();
if ($text_mode) {
return $word_part . ' ' . $text_part;
}
if ($show) {
$content = array(phutil_tag('span', array('class' => 'remarkup-note-word'), $word_part), ' ', $text_part);
} else {
$content = $text_part;
}
return phutil_tag('div', array('class' => 'remarkup-' . $class_suffix), $content);
}
示例10: buildPropertyListView
private function buildPropertyListView(DrydockResource $resource, PhabricatorActionListView $actions)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setActionList($actions);
$status = $resource->getStatus();
$status = DrydockResourceStatus::getNameForStatus($status);
$view->addProperty(pht('Status'), $status);
$until = $resource->getUntil();
if ($until) {
$until_display = phabricator_datetime($until, $viewer);
} else {
$until_display = phutil_tag('em', array(), pht('Never'));
}
$view->addProperty(pht('Expires'), $until_display);
$view->addProperty(pht('Resource Type'), $resource->getType());
$view->addProperty(pht('Blueprint'), $viewer->renderHandle($resource->getBlueprintPHID()));
$attributes = $resource->getAttributes();
if ($attributes) {
$view->addSectionHeader(pht('Attributes'), 'fa-list-ul');
foreach ($attributes as $key => $value) {
$view->addProperty($key, $value);
}
}
return $view;
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$client = id(new PhabricatorOAuthServerClientQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$client) {
return new Aphront404Response();
}
$view_uri = $client->getViewURI();
// Look for an existing authorization.
$authorization = id(new PhabricatorOAuthClientAuthorizationQuery())->setViewer($viewer)->withUserPHIDs(array($viewer->getPHID()))->withClientPHIDs(array($client->getPHID()))->executeOne();
if ($authorization) {
return $this->newDialog()->setTitle(pht('Already Authorized'))->appendParagraph(pht('You have already authorized this application to access your ' . 'account.'))->addCancelButton($view_uri, pht('Close'));
}
if ($request->isFormPost()) {
$server = id(new PhabricatorOAuthServer())->setUser($viewer)->setClient($client);
$scope = array();
$authorization = $server->authorizeClient($scope);
$id = $authorization->getID();
$panel_uri = '/settings/panel/oauthorizations/?id=' . $id;
return id(new AphrontRedirectResponse())->setURI($panel_uri);
}
// TODO: It would be nice to put scope options in this dialog, maybe?
return $this->newDialog()->setTitle(pht('Authorize Application?'))->appendParagraph(pht('This will create an authorization, permitting %s to access ' . 'your account.', phutil_tag('strong', array(), $client->getName())))->addCancelButton($view_uri)->addSubmitButton(pht('Authorize Application'));
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$keys = $request->getStr('keys');
try {
$keys = phutil_json_decode($keys);
} catch (PhutilJSONParserException $ex) {
return new Aphront400Response();
}
// There have been at least two users asking for a keyboard shortcut to
// close the dialog, so be explicit that escape works since it isn't
// terribly discoverable.
$keys[] = array('keys' => array('esc'), 'description' => pht('Close any dialog, including this one.'));
$stroke_map = array('left' => "←", 'right' => "→", 'up' => "↑", 'down' => "↓", 'return' => "⏎", 'tab' => "⇥", 'delete' => "⌫");
$rows = array();
foreach ($keys as $shortcut) {
$keystrokes = array();
foreach ($shortcut['keys'] as $stroke) {
$stroke = idx($stroke_map, $stroke, $stroke);
$keystrokes[] = phutil_tag('kbd', array(), $stroke);
}
$keystrokes = phutil_implode_html(' or ', $keystrokes);
$rows[] = phutil_tag('tr', array(), array(phutil_tag('th', array(), $keystrokes), phutil_tag('td', array(), $shortcut['description'])));
}
$table = phutil_tag('table', array('class' => 'keyboard-shortcut-help'), $rows);
return $this->newDialog()->setTitle(pht('Keyboard Shortcuts'))->appendChild($table)->addCancelButton('#', pht('Close'));
}
示例13: execute
/**
* @param string $date
*/
public function execute($tasks, $recently_closed, $date)
{
$result = array();
$leftover = array();
foreach ($tasks as $task) {
$phids = $task->getProjectPHIDs();
if ($phids) {
foreach ($phids as $project_phid) {
$result[$project_phid][] = $task;
}
} else {
$leftover[] = $task;
}
}
$result_closed = array();
$leftover_closed = array();
foreach ($recently_closed as $task) {
$phids = $task->getProjectPHIDs();
if ($phids) {
foreach ($phids as $project_phid) {
$result_closed[$project_phid][] = $task;
}
} else {
$leftover_closed[] = $task;
}
}
$base_link = '/maniphest/?allProjects=';
$leftover_name = phutil_tag('em', array(), pht('(No Project)'));
$col_header = pht('Project');
$header = pht('Open Tasks by Project and Priority (%s)', $date);
return array($leftover, $base_link, $leftover_name, $col_header, $header, $result_closed, $leftover_closed, $result);
}
示例14: linkRevision
public static final function linkRevision($id)
{
if (!$id) {
return null;
}
return phutil_tag('a', array('href' => "/D{$id}"), "D{$id}");
}
示例15: 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())));
}