本文整理汇总了PHP中javelin_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP javelin_tag函数的具体用法?PHP javelin_tag怎么用?PHP javelin_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了javelin_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$content = $this->renderChildren();
if (!$content) {
return null;
}
require_celerity_resource('aphront-list-filter-view-css');
$content = phutil_tag('div', array('class' => 'aphront-list-filter-view-content'), $content);
$classes = array();
$classes[] = 'aphront-list-filter-view';
if ($this->showAction !== null) {
$classes[] = 'aphront-list-filter-view-collapsible';
Javelin::initBehavior('phabricator-reveal-content');
$hide_action_id = celerity_generate_unique_node_id();
$show_action_id = celerity_generate_unique_node_id();
$content_id = celerity_generate_unique_node_id();
$hide_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'id' => $hide_action_id, 'href' => $this->showHideHref, 'meta' => array('hideIDs' => array($hide_action_id), 'showIDs' => array($content_id, $show_action_id))), $this->showAction);
$content_description = phutil_tag('div', array('class' => 'aphront-list-filter-description'), $this->showHideDescription);
$show_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'style' => 'display: none;', 'href' => '#', 'id' => $show_action_id, 'meta' => array('hideIDs' => array($content_id, $show_action_id), 'showIDs' => array($hide_action_id))), $this->hideAction);
$reveal_block = phutil_tag('div', array('class' => 'aphront-list-filter-reveal'), array($content_description, $hide_action, $show_action));
$content = array($reveal_block, phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), $content));
}
$content = phutil_tag('div', array('class' => implode(' ', $classes)), $content);
return phutil_tag('div', array('class' => 'aphront-list-filter-wrap'), $content);
}
示例2: getTokensForTask
public function getTokensForTask($task)
{
$tokens_given = id(new PhabricatorTokenGivenQuery())->setViewer($this->viewer)->withObjectPHIDs(array($task->getPHID()))->execute();
if (!$tokens_given) {
return null;
}
$tokens = id(new PhabricatorTokenQuery())->setViewer($this->viewer)->withPHIDs(mpull($tokens_given, 'getTokenPHID'))->execute();
$tokens = mpull($tokens, null, 'getPHID');
$author_phids = mpull($tokens_given, 'getAuthorPHID');
$handles = id(new PhabricatorHandleQuery())->setViewer($this->viewer)->withPHIDs($author_phids)->execute();
Javelin::initBehavior('phabricator-tooltips');
$list = array();
foreach ($tokens_given as $token_given) {
if (!idx($tokens, $token_given->getTokenPHID())) {
continue;
}
$token = $tokens[$token_given->getTokenPHID()];
$aural = javelin_tag('span', array('aural' => true), pht('"%s" token, awarded by %s.', $token->getName(), $handles[$token_given->getAuthorPHID()]->getName()));
$tokenslabel = 'Tokens:';
$tokensvalue = phutil_tag('dd', array('class' => 'phui-card-list-value'), array($token->renderIcon(), ' '));
$tokenskey = phutil_tag('dt', array('class' => 'phui-card-list-key'), array($tokenslabel, ' '));
$list[] = javelin_tag('dl', array('sigil' => 'has-tooltip', 'class' => 'token-icon', 'meta' => array('tip' => $handles[$token_given->getAuthorPHID()]->getName())), array($aural, $tokenskey, $tokensvalue));
}
return $list;
}
示例3: phabricator_form
function phabricator_form(PhabricatorUser $user, $attributes, $content)
{
$body = array();
$http_method = idx($attributes, 'method');
$is_post = strcasecmp($http_method, 'POST') === 0;
$http_action = idx($attributes, 'action');
$is_absolute_uri = preg_match('#^(https?:|//)#', $http_action);
if ($is_post) {
// NOTE: We only include CSRF tokens if a URI is a local URI on the same
// domain. This is an important security feature and prevents forms which
// submit to foreign sites from leaking CSRF tokens.
// In some cases, we may construct a fully-qualified local URI. For example,
// we can construct these for download links, depending on configuration.
// These forms do not receive CSRF tokens, even though they safely could.
// This can be confusing, if you're developing for Phabricator and
// manage to construct a local form with a fully-qualified URI, since it
// won't get CSRF tokens and you'll get an exception at the other end of
// the request which is a bit disconnected from the actual root cause.
// However, this is rare, and there are reasonable cases where this
// construction occurs legitimately, and the simplest fix is to omit CSRF
// tokens for these URIs in all cases. The error message you receive also
// gives you some hints as to this potential source of error.
if (!$is_absolute_uri) {
$body[] = phutil_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken()));
$body[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true));
}
}
if (is_array($content)) {
$body = array_merge($body, $content);
} else {
$body[] = $content;
}
return javelin_tag('form', $attributes, $body);
}
示例4: render
public function render()
{
$rows = array();
$any_hidden = false;
foreach ($this->rows as $row) {
$style = idx($row, 'style');
switch ($style) {
case 'section':
$cells = phutil_tag('th', array('colspan' => 2), idx($row, 'name'));
break;
default:
$name = phutil_tag('th', array(), idx($row, 'name'));
$value = phutil_tag('td', array(), idx($row, 'value'));
$cells = array($name, $value);
break;
}
$show = idx($row, 'show');
$rows[] = javelin_tag('tr', array('style' => $show ? null : 'display: none', 'sigil' => $show ? null : 'differential-results-row-toggle', 'class' => 'differential-results-row-' . $style), $cells);
if (!$show) {
$any_hidden = true;
}
}
if ($any_hidden) {
$show_more = javelin_tag('a', array('href' => '#', 'mustcapture' => true), $this->showMoreString);
$hide_more = javelin_tag('a', array('href' => '#', 'mustcapture' => true), 'Hide');
$rows[] = javelin_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-show'), phutil_tag('th', array('colspan' => 2), $show_more));
$rows[] = javelin_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-hide', 'style' => 'display: none'), phutil_tag('th', array('colspan' => 2), $hide_more));
$this->initBehavior('differential-show-field-details');
}
$this->requireResource('differential-results-table-css');
return javelin_tag('table', array('class' => 'differential-results-table', 'sigil' => 'differential-results-table'), $rows);
}
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$project) {
return new Aphront404Response();
}
$edit_uri = $this->getApplicationURI('edit/' . $project->getID() . '/');
require_celerity_resource('project-icon-css');
Javelin::initBehavior('phabricator-tooltips');
$project_icons = PhabricatorProjectIcon::getIconMap();
if ($request->isFormPost()) {
$v_icon = $request->getStr('icon');
return id(new AphrontAjaxResponse())->setContent(array('value' => $v_icon, 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon)));
}
$ii = 0;
$buttons = array();
foreach ($project_icons as $icon => $label) {
$view = id(new PHUIIconView())->setIconFont($icon);
$aural = javelin_tag('span', array('aural' => true), pht('Choose "%s" Icon', $label));
if ($icon == $project->getIcon()) {
$class_extra = ' selected';
} else {
$class_extra = null;
}
$buttons[] = javelin_tag('button', array('class' => 'icon-button' . $class_extra, 'name' => 'icon', 'value' => $icon, 'type' => 'submit', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $label)), array($aural, $view));
if (++$ii % 4 == 0) {
$buttons[] = phutil_tag('br');
}
}
$buttons = phutil_tag('div', array('class' => 'icon-grid'), $buttons);
return $this->newDialog()->setTitle(pht('Choose Project Icon'))->appendChild($buttons)->addCancelButton($edit_uri);
}
示例6: render
public function render()
{
$classes = array('phui-crumb-view');
$aural = null;
if ($this->aural !== null) {
$aural = javelin_tag('span', array('aural' => true), $this->aural);
}
$icon = null;
if ($this->icon) {
$classes[] = 'phui-crumb-has-icon';
$icon = id(new PHUIIconView())->setIcon($this->icon);
}
// Surround the crumb name with spaces so that double clicking it only
// selects the crumb itself.
$name = array(' ', $this->name, ' ');
$name = phutil_tag('span', array('class' => 'phui-crumb-name'), $name);
$divider = null;
if (!$this->isLastCrumb) {
$divider = id(new PHUIIconView())->setIcon('fa-angle-right')->addClass('phui-crumb-divider')->addClass('phui-crumb-view');
} else {
$classes[] = 'phabricator-last-crumb';
}
$tag = javelin_tag($this->href ? 'a' : 'span', array('sigil' => $this->workflow ? 'workflow' : null, 'href' => $this->href, 'class' => implode(' ', $classes)), array($aural, $icon, $name));
return array($tag, $divider);
}
示例7: processRequest
public function processRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$preferences = $this->getPreferences();
$notifications_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY;
$notifications_value = $preferences->getSettingValue($notifications_key);
if ($request->isFormPost()) {
$this->writeSetting($preferences, $notifications_key, $request->getInt($notifications_key));
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
}
$title = pht('Desktop Notifications');
$control_id = celerity_generate_unique_node_id();
$status_id = celerity_generate_unique_node_id();
$browser_status_id = celerity_generate_unique_node_id();
$cancel_ask = pht('The dialog asking for permission to send desktop notifications was ' . 'closed without granting permission. Only application notifications ' . 'will be sent.');
$accept_ask = pht('Click "Save Preference" to persist these changes.');
$reject_ask = pht('Permission for desktop notifications was denied. Only application ' . 'notifications will be sent.');
$no_support = pht('This web browser does not support desktop notifications. Only ' . 'application notifications will be sent for this browser regardless of ' . 'this preference.');
$default_status = phutil_tag('span', array(), array(pht('This browser has not yet granted permission to send desktop ' . 'notifications for this Phabricator instance.'), phutil_tag('br'), phutil_tag('br'), javelin_tag('button', array('sigil' => 'desktop-notifications-permission-button', 'class' => 'green'), pht('Grant Permission'))));
$granted_status = phutil_tag('span', array(), pht('This browser has been granted permission to send desktop ' . 'notifications for this Phabricator instance.'));
$denied_status = phutil_tag('span', array(), pht('This browser has denied permission to send desktop notifications ' . 'for this Phabricator instance. Consult your browser settings / ' . 'documentation to figure out how to clear this setting, do so, ' . 'and then re-visit this page to grant permission.'));
$status_box = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setID($status_id)->setIsHidden(true)->appendChild($accept_ask);
$control_config = array('controlID' => $control_id, 'statusID' => $status_id, 'browserStatusID' => $browser_status_id, 'defaultMode' => 0, 'desktopMode' => 1, 'cancelAsk' => $cancel_ask, 'grantedAsk' => $accept_ask, 'deniedAsk' => $reject_ask, 'defaultStatus' => $default_status, 'deniedStatus' => $denied_status, 'grantedStatus' => $granted_status, 'noSupport' => $no_support);
$form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel($title)->setControlID($control_id)->setName($notifications_key)->setValue($notifications_value)->setOptions(array(1 => pht('Send Desktop Notifications Too'), 0 => pht('Send Application Notifications Only')))->setCaption(pht('Should Phabricator send desktop notifications? These are sent ' . 'in addition to the notifications within the Phabricator ' . 'application.'))->initBehavior('desktop-notifications-control', $control_config))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Preference')));
$test_button = id(new PHUIButtonView())->setTag('a')->setWorkflow(true)->setText(pht('Send Test Notification'))->setHref('/notification/test/')->setIcon('fa-exclamation-triangle');
$form_box = id(new PHUIObjectBoxView())->setHeader(id(new PHUIHeaderView())->setHeader(pht('Desktop Notifications'))->addActionLink($test_button))->setForm($form)->setInfoView($status_box)->setFormSaved($request->getBool('saved'));
$browser_status_box = id(new PHUIInfoView())->setID($browser_status_id)->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setIsHidden(true)->appendChild($default_status);
return array($form_box, $browser_status_box);
}
示例8: renderPropertyViewValue
public function renderPropertyViewValue(array $handles)
{
$requested_object = $this->getObject()->getRequestedObject();
if (!$requested_object instanceof DifferentialRevision) {
return null;
}
$diff_rev = $requested_object;
$diffs = $diff_rev->loadRelatives(new DifferentialDiff(), 'revisionID', 'getID', 'creationMethod <> "commit"');
$all_changesets = array();
$most_recent_changesets = null;
foreach ($diffs as $diff) {
$changesets = $diff->loadRelatives(new DifferentialChangeset(), 'diffID');
$all_changesets += $changesets;
$most_recent_changesets = $changesets;
}
// The score is based on all changesets for all versions of this diff
$all_changes = $this->countLinesAndPaths($all_changesets);
$points = self::LINES_WEIGHT * $all_changes['code']['lines'] + self::PATHS_WEIGHT * count($all_changes['code']['paths']);
// The blurb is just based on the most recent version of the diff
$mr_changes = $this->countLinesAndPaths($most_recent_changesets);
$test_tag = '';
if ($mr_changes['tests']['paths']) {
Javelin::initBehavior('phabricator-tooltips');
require_celerity_resource('aphront-tooltip-css');
$test_blurb = pht('%d line(s)', $mr_changes['tests']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['tests']['paths'])) . " contain changes to test code:\n";
foreach ($mr_changes['tests']['paths'] as $mr_test_path) {
$test_blurb .= pht("%s\n", $mr_test_path);
}
$test_tag = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $test_blurb, 'align' => 'E', 'size' => 'auto'), 'style' => ''), ' + tests');
}
$blurb = hsprintf('%s%s.', pht('%d line(s)', $mr_changes['code']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['code']['paths'])) . ' over ' . pht('%d diff(s)', count($diffs)), $test_tag);
return id(new AphrontProgressBarView())->setValue($points)->setMax(self::MAX_POINTS)->setCaption($blurb)->render();
}
示例9: render
public function render()
{
$question = $this->question;
$viewer = $this->user;
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$viewer->getPHID()])) {
return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
}
$info_panel = null;
if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
$info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
but you can still leave a new answer.'));
}
$box_style = null;
$own_question = null;
$hide_action_id = celerity_generate_unique_node_id();
$show_action_id = celerity_generate_unique_node_id();
if ($question->getAuthorPHID() == $viewer->getPHID()) {
$box_style = 'display: none;';
$open_link = javelin_tag('a', array('sigil' => 'reveal-content', 'class' => 'mml', 'id' => $hide_action_id, 'href' => '#', 'meta' => array('showIDs' => array($show_action_id), 'hideIDs' => array($hide_action_id))), pht('Add an answer.'));
$own_question = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setID($hide_action_id)->appendChild(pht('This is your own question. You are welcome to provide
an answer if you have found a resolution.'))->appendChild($open_link);
}
$header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
$form = new AphrontFormView();
$form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
$box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
if ($info_panel) {
$box->setInfoView($info_panel);
}
$box = phutil_tag('div', array('style' => $box_style, 'class' => 'mlt', 'id' => $show_action_id), $box);
return array($own_question, $box);
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$engine = new PhabricatorSetupEngine();
$response = $engine->execute();
if ($response) {
return $response;
}
$issues = $engine->getIssues();
$unresolved_count = count($engine->getUnresolvedIssues());
if ($issues) {
require_celerity_resource('phabricator-notification-menu-css');
$items = array();
foreach ($issues as $issue) {
$classes = array();
$classes[] = 'phabricator-notification';
if ($issue->getIsIgnored()) {
$classes[] = 'phabricator-notification-read';
} else {
$classes[] = 'phabricator-notification-unread';
}
$uri = '/config/issue/' . $issue->getIssueKey() . '/';
$title = $issue->getName();
$summary = $issue->getSummary();
$items[] = javelin_tag('div', array('class' => implode(' ', $classes), 'sigil' => 'notification', 'meta' => array('href' => $uri)), $title);
}
$content = phutil_tag_div('setup-issue-menu', $items);
} else {
$content = phutil_tag_div('phabricator-notification no-notifications', pht('You have no unresolved setup issues.'));
}
$content = hsprintf('<div class="phabricator-notification-header">%s</div>' . '%s', phutil_tag('a', array('href' => '/config/issue/'), pht('Unresolved Setup Issues')), $content);
$json = array('content' => $content, 'number' => (int) $unresolved_count);
return id(new AphrontAjaxResponse())->setContent($json);
}
示例11: render
public function render()
{
$conpherence = $this->getConpherence();
$widget_data = $conpherence->getWidgetData();
$viewer = $this->getUser();
$participants = $conpherence->getParticipants();
$handles = $conpherence->getHandles();
$head_handles = array_select_keys($handles, array($viewer->getPHID()));
$handle_list = mpull($handles, 'getName');
natcasesort($handle_list);
$handles = mpull($handles, null, 'getName');
$handles = array_select_keys($handles, $handle_list);
$head_handles = mpull($head_handles, null, 'getName');
$handles = $head_handles + $handles;
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
$body = array();
foreach ($handles as $handle) {
$user_phid = $handle->getPHID();
if ($user_phid == $viewer->getPHID() || $can_edit) {
$icon = id(new PHUIIconView())->setIcon('fa-times lightbluetext');
$remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon);
} else {
$remove_html = null;
}
$body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html));
}
return $body;
}
示例12: render
public function render()
{
$conpherence = $this->conpherence;
$viewer = $this->getViewer();
$participants = $conpherence->getParticipants();
$count = new PhutilNumber(count($participants));
$handles = $conpherence->getHandles();
$handles = array_intersect_key($handles, $participants);
$head_handles = array_select_keys($handles, array($viewer->getPHID()));
$handle_list = mpull($handles, 'getName');
natcasesort($handle_list);
$handles = mpull($handles, null, 'getName');
$handles = array_select_keys($handles, $handle_list);
$head_handles = mpull($head_handles, null, 'getName');
$handles = $head_handles + $handles;
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
$body = array();
foreach ($handles as $handle) {
$user_phid = $handle->getPHID();
if ($user_phid == $viewer->getPHID() || $can_edit) {
$icon = id(new PHUIIconView())->setIcon('fa-times')->addClass('lightbluetext');
$remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon);
} else {
$remove_html = null;
}
$body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html));
}
$new_icon = id(new PHUIIconView())->setIcon('fa-plus-square')->setHref($this->updateURI)->setMetadata(array('widget' => null))->addSigil('conpherence-widget-adder');
$header = id(new PHUIHeaderView())->setHeader(pht('Participants (%d)', $count))->addClass('widgets-header')->addActionItem($new_icon);
$content = javelin_tag('div', array('class' => 'widgets-body', 'id' => 'widgets-people', 'sigil' => 'widgets-people'), array($header, $body));
return $content;
}
示例13: buildPropertyView
private function buildPropertyView(PhameBlog $blog)
{
$viewer = $this->getViewer();
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog);
$domain = $blog->getDomain();
if (!$domain) {
$domain = phutil_tag('em', array(), pht('No external domain'));
}
$properties->addProperty(pht('Domain'), $domain);
$feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
$properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $blog);
$properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
$properties->invokeWillRenderEvent();
$description = $blog->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($description);
}
return $properties;
}
示例14: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$user = $request->getUser();
$drequest = $this->getDiffusionRequest();
$callsign = $drequest->getRepository()->getCallsign();
$repository = $drequest->getRepository();
$commit = $drequest->loadCommit();
$data = $commit->loadCommitData();
$page_title = pht('Edit Diffusion Commit');
if (!$commit) {
return new Aphront404Response();
}
$commit_phid = $commit->getPHID();
$edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($commit_phid, $edge_type);
if ($request->isFormPost()) {
$xactions = array();
$proj_phids = $request->getArr('projects');
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edge_type)->setNewValue(array('=' => array_fuse($proj_phids)));
$editor = id(new PhabricatorAuditEditor())->setActor($user)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
$xactions = $editor->applyTransactions($commit, $xactions);
return id(new AphrontRedirectResponse())->setURI('/r' . $callsign . $commit->getCommitIdentifier());
}
$tokenizer_id = celerity_generate_unique_node_id();
$form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Projects'))->setName('projects')->setValue($current_proj_phids)->setID($tokenizer_id)->setCaption(javelin_tag('a', array('href' => '/project/create/', 'mustcapture' => true, 'sigil' => 'project-create'), pht('Create New Project')))->setDatasource(new PhabricatorProjectDatasource()));
$reason = $data->getCommitDetail('autocloseReason', false);
$reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED;
if ($reason !== false) {
switch ($reason) {
case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
$desc = pht('No, Repository Importing');
break;
case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
$desc = pht('No, Autoclose Disabled');
break;
case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH:
$desc = pht('No, Not On Autoclose Branch');
break;
case PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED:
$desc = pht('Yes, Forced Via bin/repository CLI Tool.');
break;
case null:
$desc = pht('Yes');
break;
default:
$desc = pht('Unknown');
break;
}
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
$doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Learn More'));
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Autoclose?'))->setValue(array($desc, " · ", $doc_link)));
}
Javelin::initBehavior('project-create', array('tokenizerID' => $tokenizer_id));
$submit = id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton('/r' . $callsign . $commit->getCommitIdentifier());
$form->appendChild($submit);
$crumbs = $this->buildCrumbs(array('commit' => true));
$crumbs->addTextCrumb(pht('Edit'));
$form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setForm($form);
return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $page_title));
}
示例15: render
public function render()
{
require_celerity_resource('sprite-docs-css');
$conpherence = $this->getConpherence();
$widget_data = $conpherence->getWidgetData();
$files = $widget_data['files'];
$files_authors = $widget_data['files_authors'];
$files_html = array();
foreach ($files as $file) {
$icon_class = $file->getDisplayIconForMimeType();
$icon_view = phutil_tag('div', array('class' => 'file-icon sprite-docs ' . $icon_class), '');
$file_view = id(new PhabricatorFileLinkView())->setFilePHID($file->getPHID())->setFileName(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(28)->truncateString($file->getName()))->setFileViewable($file->isViewableImage())->setFileViewURI($file->getBestURI())->setCustomClass('file-title');
$who_done_it_text = '';
// system generated files don't have authors
if ($file->getAuthorPHID()) {
$who_done_it_text = pht('By %s ', $files_authors[$file->getPHID()]->renderLink());
}
$date_text = phabricator_relative_date($file->getDateCreated(), $this->getUser());
$who_done_it = phutil_tag('div', array('class' => 'file-uploaded-by'), pht('%s%s.', $who_done_it_text, $date_text));
$files_html[] = phutil_tag('div', array('class' => 'file-entry'), array($icon_view, $file_view, $who_done_it));
}
if (empty($files)) {
$files_html[] = javelin_tag('div', array('class' => 'no-files', 'sigil' => 'no-files'), pht('No files.'));
}
return phutil_tag('div', array('class' => 'file-list'), $files_html);
}