本文整理汇总了PHP中phabricator_form函数的典型用法代码示例。如果您正苦于以下问题:PHP phabricator_form函数的具体用法?PHP phabricator_form怎么用?PHP phabricator_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phabricator_form函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSettingsWidgetPaneContent
private function renderSettingsWidgetPaneContent()
{
$viewer = $this->getViewer();
$conpherence = $this->getConpherence();
$participant = $conpherence->getParticipantIfExists($viewer->getPHID());
if (!$participant) {
$can_join = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_JOIN);
if ($can_join) {
$text = pht('Notification settings are available after joining the room.');
} else {
if ($viewer->isLoggedIn()) {
$text = pht('Notification settings not applicable to rooms you can not join.');
} else {
$text = pht('Notification settings are available after logging in and joining ' . 'the room.');
}
}
return phutil_tag('div', array('class' => 'no-settings'), $text);
}
$notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY;
$notification_default = $viewer->getUserSetting($notification_key);
$settings = $participant->getSettings();
$notifications = idx($settings, 'notifications', $notification_default);
$options = id(new AphrontFormRadioButtonControl())->addButton(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, PhabricatorConpherenceNotificationsSetting::getSettingLabel(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), '')->addButton(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, PhabricatorConpherenceNotificationsSetting::getSettingLabel(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), '')->setName('notifications')->setValue($notifications);
$layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
return phabricator_form($viewer, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
}
示例2: render
public function render()
{
if (!$this->uri) {
throw new PhutilInvalidStateException('setSubmitURI');
}
$viewer = $this->getViewer();
$content = phabricator_form($viewer, array('action' => $this->uri, 'method' => 'POST', 'sigil' => 'inline-edit-form'), array($this->renderInputs(), $this->renderBody()));
return $content;
}
示例3: render
public function render()
{
if (!$this->uri) {
throw new Exception('Call setSubmitURI() before render()!');
}
if (!$this->user) {
throw new Exception('Call setUser() before render()!');
}
$content = phabricator_form($this->user, array('action' => $this->uri, 'method' => 'POST', 'sigil' => 'inline-edit-form'), array($this->renderInputs(), $this->renderBody()));
return phutil_tag('table', array(), phutil_tag('tr', array('class' => 'inline-comment-splint'), array(phutil_tag('th', array()), phutil_tag('td', array('class' => 'left'), $this->onRight ? null : $content), phutil_tag('th', array()), phutil_tag('td', array('colspan' => 3, 'class' => 'right3'), $this->onRight ? $content : null))));
}
示例4: buildSearchForm
public function buildSearchForm()
{
$viewer = $this->getViewer();
$conpherence = $this->conpherence;
$name = $conpherence->getTitle();
$bar = javelin_tag('input', array('type' => 'text', 'id' => 'conpherence-search-input', 'name' => 'fulltext', 'class' => 'conpherence-search-input', 'sigil' => 'conpherence-search-input', 'placeholder' => pht('Search %s...', $name)));
$id = $conpherence->getID();
$form = phabricator_form($viewer, array('method' => 'POST', 'action' => '/conpherence/threadsearch/' . $id . '/', 'sigil' => 'conpherence-search-form', 'class' => 'conpherence-search-form', 'id' => 'conpherence-search-form'), array($bar));
$form_view = phutil_tag('div', array('class' => 'conpherence-search-form-view'), $form);
$results = phutil_tag('div', array('id' => 'conpherence-search-results', 'class' => 'conpherence-search-results'));
$view = phutil_tag('div', array('class' => 'conpherence-search-window'), array($form_view, $results));
return $view;
}
示例5: render
public function render()
{
$user = $this->user;
$target_id = celerity_generate_unique_node_id();
$search_id = $this->getID();
$button_id = celerity_generate_unique_node_id();
$input = phutil_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off'));
$target = javelin_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), '');
$search_datasource = new PhabricatorSearchDatasource();
Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'button' => $button_id, 'src' => $search_datasource->getDatasourceURI(), 'limit' => 10, 'placeholder' => pht('Search')));
$primary_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'search:primary', 'value' => 'true'));
$form = phabricator_form($user, array('action' => '/search/', 'method' => 'POST'), phutil_tag_div('phabricator-main-menu-search-container', array($input, phutil_tag('button', array('id' => $button_id), pht('Search')), $primary_input, $target)));
return $form;
}
示例6: renderOptionButton
private function renderOptionButton(array $option)
{
$viewer = $this->getViewer();
$icon = idx($option, 'icon');
if ($icon) {
$preview_class = null;
$preview_content = id(new PHUIIconView())->setIcon($icon, 'lightbluetext');
} else {
$preview_class = 'phui-workboard-' . $option['key'];
$preview_content = null;
}
$preview = phutil_tag('div', array('class' => 'phui-workboard-color-preview ' . $preview_class), $preview_content);
$button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $option['name'], 'size' => 300)), $preview);
$input = phutil_tag('input', array('type' => 'hidden', 'name' => 'backgroundKey', 'value' => $option['key']));
return phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($button, $input));
}
示例7: renderSettingsWidgetPaneContent
private function renderSettingsWidgetPaneContent()
{
$user = $this->getRequest()->getUser();
$conpherence = $this->getConpherence();
$participants = $conpherence->getParticipants();
$participant = $participants[$user->getPHID()];
$default = ConpherenceSettings::EMAIL_ALWAYS;
$preference = $this->getUserPreferences();
if ($preference) {
$default = $preference->getPreference(PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS, ConpherenceSettings::EMAIL_ALWAYS);
}
$settings = $participant->getSettings();
$notifications = idx($settings, 'notifications', $default);
$options = id(new AphrontFormRadioButtonControl())->addButton(ConpherenceSettings::EMAIL_ALWAYS, ConpherenceSettings::getHumanString(ConpherenceSettings::EMAIL_ALWAYS), '')->addButton(ConpherenceSettings::NOTIFICATIONS_ONLY, ConpherenceSettings::getHumanString(ConpherenceSettings::NOTIFICATIONS_ONLY), '')->setName('notifications')->setValue($notifications);
$layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
return phabricator_form($user, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
}
示例8: render
public function render()
{
$user = $this->user;
$target_id = celerity_generate_unique_node_id();
$search_id = $this->getID();
$button_id = celerity_generate_unique_node_id();
$selector_id = celerity_generate_unique_node_id();
$application_id = celerity_generate_unique_node_id();
$input = phutil_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off'));
$target = javelin_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), '');
$search_datasource = new PhabricatorSearchDatasource();
$scope_key = PhabricatorUserPreferences::PREFERENCE_SEARCH_SCOPE;
Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'button' => $button_id, 'selectorID' => $selector_id, 'applicationID' => $application_id, 'defaultApplicationIcon' => self::DEFAULT_APPLICATION_ICON, 'appScope' => PhabricatorSearchController::SCOPE_CURRENT_APPLICATION, 'src' => $search_datasource->getDatasourceURI(), 'limit' => 10, 'placeholder' => pht('Search'), 'scopeUpdateURI' => '/settings/adjust/?key=' . $scope_key));
$primary_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'search:primary', 'value' => 'true'));
$search_text = javelin_tag('span', array('aural' => true), pht('Search'));
$selector = $this->buildModeSelector($selector_id, $application_id);
$form = phabricator_form($user, array('action' => '/search/', 'method' => 'POST'), phutil_tag_div('phabricator-main-menu-search-container', array($input, phutil_tag('button', array('id' => $button_id, 'class' => 'phui-icon-view phui-font-fa fa-search'), $search_text), $selector, $primary_input, $target)));
return $form;
}
示例9: renderLoginForm
protected function renderLoginForm(AphrontRequest $request, $mode)
{
$viewer = $request->getUser();
if ($mode == 'link') {
$button_text = pht('Link External Account');
} else {
if ($mode == 'refresh') {
$button_text = pht('Refresh Account Link');
} else {
if ($this->shouldAllowRegistration()) {
$button_text = pht('Login or Register');
} else {
$button_text = pht('Login');
}
}
}
$icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getLoginIcon());
$button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($button_text)->setSubtext($this->getProviderName());
$content = array($button);
$uri = $this->getLoginURI();
return phabricator_form($viewer, array('method' => 'GET', 'action' => (string) $uri), $content);
}
示例10: renderBatchEditor
private function renderBatchEditor(PhabricatorSavedQuery $saved_query)
{
$user = $this->getUser();
if (!$this->canBatchEdit) {
return null;
}
if (!$user->isLoggedIn()) {
// Don't show the batch editor or excel export for logged-out users.
// Technically we //could// let them export, but ehh.
return null;
}
Javelin::initBehavior('maniphest-batch-selector', array('selectAll' => 'batch-select-all', 'selectNone' => 'batch-select-none', 'submit' => 'batch-select-submit', 'status' => 'batch-select-status-cell', 'idContainer' => 'batch-select-id-container', 'formID' => 'batch-select-form'));
$select_all = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-all'), pht('Select All'));
$select_none = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-none'), pht('Clear Selection'));
$submit = phutil_tag('button', array('id' => 'batch-select-submit', 'disabled' => 'disabled', 'class' => 'disabled'), pht("Batch Edit Selected »"));
$export = javelin_tag('a', array('href' => '/maniphest/export/' . $saved_query->getQueryKey() . '/', 'class' => 'grey button'), pht('Export to Excel'));
$hidden = phutil_tag('div', array('id' => 'batch-select-id-container'), '');
$editor = hsprintf('<table class="maniphest-batch-editor-layout">' . '<tr>' . '<td>%s%s</td>' . '<td>%s</td>' . '<td id="batch-select-status-cell">%s</td>' . '<td class="batch-select-submit-cell">%s%s</td>' . '</tr>' . '</table>', $select_all, $select_none, $export, '', $submit, $hidden);
$editor = phabricator_form($user, array('method' => 'POST', 'action' => '/maniphest/batch/', 'id' => 'batch-select-form'), $editor);
$box = id(new PHUIObjectBoxView())->setHeaderText(pht('Batch Task Editor'))->appendChild($editor);
$content = phutil_tag_div('maniphest-batch-editor', $box);
return $content;
}
示例11: render
public function render()
{
$this->requireResource('differential-core-view-css');
$this->requireResource('differential-revision-history-css');
$data = array(array('name' => 'Base', 'id' => null, 'desc' => 'Base', 'age' => null, 'obj' => null));
$seq = 0;
foreach ($this->diffs as $diff) {
$data[] = array('name' => 'Diff ' . ++$seq, 'id' => $diff->getID(), 'desc' => $diff->getDescription(), 'age' => $diff->getDateCreated(), 'obj' => $diff);
}
$max_id = $diff->getID();
$idx = 0;
$rows = array();
$disable = false;
$radios = array();
$last_base = null;
$rowc = array();
foreach ($data as $row) {
$diff = $row['obj'];
$name = $row['name'];
$id = $row['id'];
$old_class = false;
$new_class = false;
if ($id) {
$new_checked = $this->selectedDiffID == $id;
$new = javelin_tag('input', array('type' => 'radio', 'name' => 'id', 'value' => $id, 'checked' => $new_checked ? 'checked' : null, 'sigil' => 'differential-new-radio'));
if ($new_checked) {
$new_class = true;
$disable = true;
}
$new = phutil_tag('div', array('class' => 'differential-update-history-radio'), $new);
} else {
$new = null;
}
if ($max_id != $id) {
$uniq = celerity_generate_unique_node_id();
$old_checked = $this->selectedVersusDiffID == $id;
$old = phutil_tag('input', array('type' => 'radio', 'name' => 'vs', 'value' => $id, 'id' => $uniq, 'checked' => $old_checked ? 'checked' : null, 'disabled' => $disable ? 'disabled' : null));
$radios[] = $uniq;
if ($old_checked) {
$old_class = true;
}
$old = phutil_tag('div', array('class' => 'differential-update-history-radio'), $old);
} else {
$old = null;
}
$desc = $row['desc'];
if ($row['age']) {
$age = phabricator_datetime($row['age'], $this->getUser());
} else {
$age = null;
}
if ($diff) {
$lint = self::renderDiffLintStar($row['obj']);
$lint = phutil_tag('div', array('class' => 'lintunit-star', 'title' => self::getDiffLintMessage($diff)), $lint);
$unit = self::renderDiffUnitStar($row['obj']);
$unit = phutil_tag('div', array('class' => 'lintunit-star', 'title' => self::getDiffUnitMessage($diff)), $unit);
$base = $this->renderBaseRevision($diff);
} else {
$lint = null;
$unit = null;
$base = null;
}
if ($last_base !== null && $base !== $last_base) {
// TODO: Render some kind of notice about rebases.
}
$last_base = $base;
$id_link = phutil_tag('a', array('href' => '/differential/diff/' . $id . '/'), $id);
$rows[] = array($name, $id_link, $base, $desc, $age, $lint, $unit, $old, $new);
$classes = array();
if ($old_class) {
$classes[] = 'differential-update-history-old-now';
}
if ($new_class) {
$classes[] = 'differential-update-history-new-now';
}
$rowc[] = nonempty(implode(' ', $classes), null);
}
Javelin::initBehavior('differential-diff-radios', array('radios' => $radios));
$options = array(DifferentialChangesetParser::WHITESPACE_IGNORE_FORCE => 'Ignore All', DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => 'Ignore Most', DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING => 'Ignore Trailing', DifferentialChangesetParser::WHITESPACE_SHOW_ALL => 'Show All');
foreach ($options as $value => $label) {
$options[$value] = phutil_tag('option', array('value' => $value, 'selected' => $value == $this->selectedWhitespace ? 'selected' : null), $label);
}
$select = phutil_tag('select', array('name' => 'whitespace'), $options);
$table = id(new AphrontTableView($rows));
$table->setHeaders(array(pht('Diff'), pht('ID'), pht('Base'), pht('Description'), pht('Created'), pht('Lint'), pht('Unit'), '', ''));
$table->setColumnClasses(array('pri', '', '', 'wide', 'date', 'center', 'center', 'center differential-update-history-old', 'center differential-update-history-new'));
$table->setRowClasses($rowc);
$table->setDeviceVisibility(array(true, true, false, true, false, false, false, true, true));
$show_diff = phutil_tag('div', array('class' => 'differential-update-history-footer'), array(phutil_tag('label', array(), array(pht('Whitespace Changes:'), $select)), phutil_tag('button', array(), pht('Show Diff'))));
$content = phabricator_form($this->getUser(), array('action' => '#toc'), array($table, $show_diff));
return id(new PHUIObjectBoxView())->setHeaderText(pht('Revision Update History'))->setFlush(true)->appendChild($content);
}
示例12: renderStandardLoginButton
/**
* Render a standard login/register button element.
*
* The `$attributes` parameter takes these keys:
*
* - `uri`: URI the button should take the user to when clicked.
* - `method`: Optional HTTP method the button should use, defaults to GET.
*
* @param AphrontRequest HTTP request.
* @param string Request mode string.
* @param map Additional parameters, see above.
* @return wild Login button.
*/
protected function renderStandardLoginButton(AphrontRequest $request, $mode, array $attributes = array())
{
PhutilTypeSpec::checkMap($attributes, array('method' => 'optional string', 'uri' => 'string', 'sigil' => 'optional string'));
$viewer = $request->getUser();
$adapter = $this->getAdapter();
if ($mode == 'link') {
$button_text = pht('Link External Account');
} else {
if ($mode == 'refresh') {
$button_text = pht('Refresh Account Link');
} else {
if ($mode == 'invite') {
$button_text = pht('Register Account');
} else {
if ($this->shouldAllowRegistration()) {
$button_text = pht('Login or Register');
} else {
$button_text = pht('Login');
}
}
}
}
$icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getLoginIcon());
$button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($button_text)->setSubtext($this->getProviderName());
$uri = $attributes['uri'];
$uri = new PhutilURI($uri);
$params = $uri->getQueryParams();
$uri->setQueryParams(array());
$content = array($button);
foreach ($params as $key => $value) {
$content[] = phutil_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
return phabricator_form($viewer, array('method' => idx($attributes, 'method', 'GET'), 'action' => (string) $uri, 'sigil' => idx($attributes, 'sigil')), $content);
}
示例13: render
public function render()
{
$icon = null;
if ($this->icon) {
$color = '';
if ($this->disabled) {
$color = ' grey';
}
$icon = id(new PHUIIconView())->addClass('phabricator-action-view-icon')->setIcon($this->icon . $color);
}
if ($this->href) {
$sigils = array();
if ($this->workflow) {
$sigils[] = 'workflow';
}
if ($this->download) {
$sigils[] = 'download';
}
if ($this->sigils) {
$sigils = array_merge($sigils, $this->sigils);
}
$sigils = $sigils ? implode(' ', $sigils) : null;
if ($this->renderAsForm) {
if (!$this->user) {
throw new Exception(pht('Call %s when rendering an action as a form.', 'setUser()'));
}
$item = javelin_tag('button', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
$item = phabricator_form($this->user, array('action' => $this->getHref(), 'method' => 'POST', 'sigil' => $sigils, 'meta' => $this->metadata), $item);
} else {
if ($this->getOpenInNewWindow()) {
$target = '_blank';
} else {
$target = null;
}
$item = javelin_tag('a', array('href' => $this->getHref(), 'class' => 'phabricator-action-view-item', 'target' => $target, 'sigil' => $sigils, 'meta' => $this->metadata), array($icon, $this->name));
}
} else {
$item = phutil_tag('span', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
}
$classes = array();
$classes[] = 'phabricator-action-view';
if ($this->disabled) {
$classes[] = 'phabricator-action-view-disabled';
}
if ($this->label) {
$classes[] = 'phabricator-action-view-label';
}
if ($this->selected) {
$classes[] = 'phabricator-action-view-selected';
}
return phutil_tag('li', array('class' => implode(' ', $classes)), $item);
}
示例14: 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() . '/');
$view_uri = $this->getApplicationURI('view/' . $project->getID() . '/');
$supported_formats = PhabricatorFile::getTransformableImageFormats();
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else {
if ($phid) {
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
} else {
$e_file = pht('Required');
$errors[] = pht('You must choose a file when uploading a new project picture.');
}
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
$errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
} else {
$xformer = new PhabricatorImageTransformer();
$xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)->setNewValue($new_value);
$editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
$editor->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
}
}
$title = pht('Edit Project Picture');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($project->getName(), $view_uri);
$crumbs->addTextCrumb(pht('Edit'), $edit_uri);
$crumbs->addTextCrumb(pht('Picture'));
$form = id(new PHUIFormLayoutView())->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'project.png');
$images = array();
$current = $project->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
if ($files) {
$file = head($files);
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
$button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
$button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
}
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
$launch_id = celerity_generate_unique_node_id();
$input_id = celerity_generate_unique_node_id();
Javelin::initBehavior('launch-icon-composer', array('launchID' => $launch_id, 'inputID' => $input_id));
$compose_button = javelin_tag('button', array('class' => 'grey', 'id' => $launch_id, 'sigil' => 'icon-composer'), pht('Choose Icon and Color...'));
$compose_input = javelin_tag('input', array('type' => 'hidden', 'id' => $input_id, 'name' => 'phid'));
$compose_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($compose_input, $compose_button));
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Quick Create'))->setValue($compose_form));
$upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($edit_uri)->setValue(pht('Upload Picture')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
$upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
return $this->buildApplicationPage(array($crumbs, $form_box, $upload_box), array('title' => $title));
}
示例15: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$monogram = $conpherence->getMonogram();
$supported_formats = PhabricatorFile::getTransformableImageFormats();
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else {
if ($phid) {
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
} else {
$e_file = pht('Required');
$errors[] = pht('You must choose a file when uploading a new room picture.');
}
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
$errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
} else {
$xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$xformed->attachToObject($conpherence->getPHID());
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($new_value);
$editor = id(new ConpherenceEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
$editor->applyTransactions($conpherence, $xactions);
return id(new AphrontRedirectResponse())->setURI('/' . $monogram);
}
}
$title = pht('Edit Room Picture');
$form = id(new PHUIFormLayoutView())->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
$images = array();
$current = $conpherence->getProfileImagePHID();
$has_current = false;
if ($current) {
$file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->executeOne();
if ($file) {
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
$button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
$button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
}
$form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
$upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/' . $monogram)->setValue(pht('Upload Picture')));
$upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($conpherence->getTitle(), '/' . $monogram);
$crumbs->addTextCrumb(pht('Room Picture'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())->setHeader(pht('Edit Room Picture'))->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $upload_box));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($view));
}