本文整理汇总了PHP中AphrontFormView类的典型用法代码示例。如果您正苦于以下问题:PHP AphrontFormView类的具体用法?PHP AphrontFormView怎么用?PHP AphrontFormView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AphrontFormView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
{
$options = array();
$author_value = null;
$owner_value = null;
$subscribers_value = null;
$project_value = null;
$author_phids = $saved->getParameter('authorPHIDs', array());
$owner_phids = $saved->getParameter('ownerPHIDs', array());
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
$project_phids = $saved->getParameter('projectPHIDs', array());
$all_phids = array_merge($author_phids, $owner_phids, $subscriber_phids, $project_phids);
$all_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
$author_handles = array_select_keys($all_handles, $author_phids);
$owner_handles = array_select_keys($all_handles, $owner_phids);
$subscriber_handles = array_select_keys($all_handles, $subscriber_phids);
$project_handles = array_select_keys($all_handles, $project_phids);
$with_unowned = $saved->getParameter('withUnowned', array());
$status_values = $saved->getParameter('statuses', array());
$status_values = array_fuse($status_values);
$statuses = array(PhabricatorSearchRelationship::RELATIONSHIP_OPEN => pht('Open'), PhabricatorSearchRelationship::RELATIONSHIP_CLOSED => pht('Closed'));
$status_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Status'));
foreach ($statuses as $status => $name) {
$status_control->addCheckbox('statuses[]', $status, $name, isset($status_values[$status]));
}
$type_values = $saved->getParameter('types', array());
$type_values = array_fuse($type_values);
$types = self::getIndexableDocumentTypes($this->requireViewer());
$types_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Types'));
foreach ($types as $type => $name) {
$types_control->addCheckbox('types[]', $type, $name, isset($type_values[$type]));
}
$form->appendChild(phutil_tag('input', array('type' => 'hidden', 'name' => 'jump', 'value' => 'no')))->appendChild(id(new AphrontFormTextControl())->setLabel('Query')->setName('query')->setValue($saved->getParameter('query')))->appendChild($status_control)->appendChild($types_control)->appendChild(id(new AphrontFormTokenizerControl())->setName('authorPHIDs')->setLabel('Authors')->setDatasource(new PhabricatorPeopleDatasource())->setValue($author_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('ownerPHIDs')->setLabel('Owners')->setDatasource(new PhabricatorTypeaheadOwnerDatasource())->setValue($owner_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('withUnowned', 1, pht('Show only unowned documents.'), $with_unowned))->appendChild(id(new AphrontFormTokenizerControl())->setName('subscriberPHIDs')->setLabel('Subscribers')->setDatasource(new PhabricatorPeopleDatasource())->setValue($subscriber_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('projectPHIDs')->setLabel('In Any Project')->setDatasource(new PhabricatorProjectDatasource())->setValue($project_handles));
}
示例2: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$phids = $saved_query->getParameter('authorPHIDs', array());
$author_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
$upcoming = $saved_query->getParameter('upcoming');
$form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('upcoming', 1, pht('Show only countdowns that are still counting down.'), $upcoming));
}
示例3: 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);
}
示例4: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$user_phids = $saved_query->getParameter('userPHIDs', array());
$ended = $saved_query->getParameter('ended', PhrequentUserTimeQuery::ENDED_ALL);
$order = $saved_query->getParameter('order', PhrequentUserTimeQuery::ORDER_ENDED_DESC);
$form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('users')->setLabel(pht('Users'))->setValue($user_phids))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Ended'))->setName('ended')->setValue($ended)->setOptions(PhrequentUserTimeQuery::getEndedSearchOptions()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Order'))->setName('order')->setValue($order)->setOptions(PhrequentUserTimeQuery::getOrderSearchOptions()));
}
示例5: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$author_phids = $saved_query->getParameter('authorPHIDs', array());
$content_type = $saved_query->getParameter('contentType');
$rule_type = $saved_query->getParameter('ruleType');
$form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendChild(id(new AphrontFormSelectControl())->setName('contentType')->setLabel(pht('Content Type'))->setValue($content_type)->setOptions($this->getContentTypeOptions()))->appendChild(id(new AphrontFormSelectControl())->setName('ruleType')->setLabel(pht('Rule Type'))->setValue($rule_type)->setOptions($this->getRuleTypeOptions()))->appendChild(id(new AphrontFormSelectControl())->setName('disabled')->setLabel(pht('Rule Status'))->setValue($this->getBoolFromQuery($saved_query, 'disabled'))->setOptions(array('' => pht('Show Enabled and Disabled Rules'), 'false' => pht('Show Only Enabled Rules'), 'true' => pht('Show Only Disabled Rules'))));
}
示例6: processRequest
public function processRequest()
{
$event = id(new PhabricatorTimelineEvent('NULL'))->load($this->id);
if (!$event) {
return new Aphront404Response();
}
$request = $this->getRequest();
$user = $request->getUser();
if ($event->getDataID()) {
$data = id(new PhabricatorTimelineEventData())->load($event->getDataID());
}
if ($data) {
$data = json_encode($data->getEventData());
} else {
$data = 'null';
}
$form = new AphrontFormView();
$form->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($event->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($event->getType()))->appendChild(id(new AphrontFormTextAreaControl())->setDisabled(true)->setLabel('Data')->setValue($data))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/timeline/'));
$panel = new AphrontPanelView();
$panel->setHeader('Event');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
$nav = $this->buildSideNavView();
$nav->selectFilter('timeline');
$nav->appendChild($panel);
return $this->buildApplicationPage($nav, array('title' => 'Timeline Event'));
}
示例7: processRequest
public function processRequest(AphrontRequest $request)
{
$user = $request->getUser();
$username = $user->getUsername();
$pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
$pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
$pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
$preferences = $user->loadPreferences();
$errors = array();
if ($request->isFormPost()) {
$new_timezone = $request->getStr('timezone');
if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
$user->setTimezoneIdentifier($new_timezone);
} else {
$errors[] = pht('The selected timezone is not a valid timezone.');
}
$preferences->setPreference($pref_time, $request->getStr($pref_time))->setPreference($pref_date, $request->getStr($pref_date))->setPreference($pref_week_start, $request->getStr($pref_week_start));
if (!$errors) {
$preferences->save();
$user->save();
return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
}
}
$timezone_ids = DateTimeZone::listIdentifiers();
$timezone_id_map = array_fuse($timezone_ids);
$form = new AphrontFormView();
$form->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Timezone'))->setName('timezone')->setOptions($timezone_id_map)->setValue($user->getTimezoneIdentifier()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Time-of-Day Format'))->setName($pref_time)->setOptions(array('g:i A' => pht('12-hour (2:34 PM)'), 'H:i' => pht('24-hour (14:34)')))->setCaption(pht('Format used when rendering a time of day.'))->setValue($preferences->getPreference($pref_time)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Date Format'))->setName($pref_date)->setOptions(array('Y-m-d' => pht('ISO 8601 (2000-02-28)'), 'n/j/Y' => pht('US (2/28/2000)'), 'd-m-Y' => pht('European (28-02-2000)')))->setCaption(pht('Format used when rendering a date.'))->setValue($preferences->getPreference($pref_date)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Week Starts On'))->setOptions($this->getWeekDays())->setName($pref_week_start)->setCaption(pht('Calendar weeks will start with this day.'))->setValue($preferences->getPreference($pref_week_start, 0)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Account Settings')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Date and Time Settings'))->setFormSaved($request->getStr('saved'))->setFormErrors($errors)->setForm($form);
return array($form_box);
}
示例8: processRequest
public function processRequest()
{
if ($this->id) {
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
} else {
$macro = new PhabricatorFileImageMacro();
}
$errors = array();
$e_name = true;
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$macro->setName($request->getStr('name'));
if (!strlen($macro->getName())) {
$errors[] = 'Macro name is required.';
$e_name = 'Required';
} else {
if (!preg_match('/^[a-z0-9_-]{3,}$/', $macro->getName())) {
$errors[] = 'Macro must be at least three characters long and contain ' . 'only lowercase letters, digits, hyphen and underscore.';
$e_name = 'Invalid';
} else {
$e_name = null;
}
}
if (!$errors) {
$file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $user->getPHID()));
$macro->setFilePHID($file->getPHID());
try {
$macro->save();
return id(new AphrontRedirectResponse())->setURI('/file/macro/');
} catch (AphrontQueryDuplicateKeyException $ex) {
$errors[] = 'Macro name is not unique!';
$e_name = 'Duplicate';
}
}
}
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Form Errors');
$error_view->setErrors($errors);
} else {
$error_view = null;
}
$form = new AphrontFormView();
$form->setAction('/file/macro/edit/');
$form->setUser($request->getUser());
$form->setEncType('multipart/form-data')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($macro->getName())->setCaption('This word or phrase will be replaced with the image.')->setError($e_name))->appendChild(id(new AphrontFormFileControl())->setLabel('File')->setName('file')->setError(true))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save Image Macro')->addCancelButton('/file/macro/'));
$panel = new AphrontPanelView();
if ($macro->getID()) {
$panel->setHeader('Edit Image Macro');
} else {
$panel->setHeader('Create Image Macro');
}
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Image Macro'));
}
示例9: renderValidateFactorForm
public function renderValidateFactorForm(PhabricatorAuthFactorConfig $config, AphrontFormView $form, PhabricatorUser $viewer, $validation_result)
{
if (!$validation_result) {
$validation_result = array();
}
$form->appendChild(id(new AphrontFormTextControl())->setName($this->getParameterName($config, 'totpcode'))->setLabel(pht('App Code'))->setCaption(pht('Factor Name: %s', $config->getFactorName()))->setValue(idx($validation_result, 'value'))->setError(idx($validation_result, 'error', true)));
}
示例10: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
{
$backer_phids = $saved->getParameter('backerPHIDs', array());
$all_phids = array_mergev(array($backer_phids));
$handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
$form->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Backers'))->setName('backers')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $backer_phids)));
}
示例11: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$user_phids = $saved_query->getParameter('userPHIDs', array());
$proj_phids = $saved_query->getParameter('projectPHIDs', array());
$viewer_projects = $saved_query->getParameter('viewerProjects');
$form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('users')->setLabel(pht('Include Users'))->setValue($user_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Include Projects'))->setValue($proj_phids))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('viewerProjects', 1, pht('Include stories about projects I am a member of.'), $viewer_projects));
}
示例12: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($request->getStr('obj'));
if (!$receiver) {
throw new Exception("No such task or revision!");
}
$hash = PhabricatorMetaMTAReceivedMail::computeMailHash($receiver->getMailKey(), $user->getPHID());
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders(array('to' => $request->getStr('obj') . '+' . $user->getID() . '+' . $hash . '@'));
$received->setBodies(array('text' => $request->getStr('body')));
$received->save();
$received->processReceivedMail();
$phid = $receiver->getPHID();
$handles = $this->loadViewerHandles(array($phid));
$uri = $handles[$phid]->getURI();
return id(new AphrontRedirectResponse())->setURI($uri);
}
$form = new AphrontFormView();
$form->setUser($request->getUser());
$form->setAction($this->getApplicationURI('/receive/'));
$form->appendChild('<p class="aphront-form-instructions">This form will simulate ' . 'sending mail to an object.</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('To')->setName('obj')->setCaption('e.g. <tt>D1234</tt> or <tt>T1234</tt>'))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Body')->setName('body'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Receive Mail'));
$panel = new AphrontPanelView();
$panel->setHeader('Receive Email');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->buildSideNavView();
$nav->selectFilter('receive');
$nav->appendChild($panel);
return $this->buildApplicationPage($nav, array('title' => 'Receive Test'));
}
示例13: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$author_phids = $saved_query->getParameter('authorPHIDs', array());
$voted = $saved_query->getParameter('voted', false);
$statuses = $saved_query->getParameter('statuses', array());
$form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('voted', 1, pht("Show only polls I've voted in."), $voted))->appendChild(id(new AphrontFormCheckboxControl())->setLabel(pht('Status'))->addCheckbox('statuses[]', 'open', pht('Open'), in_array('open', $statuses))->addCheckbox('statuses[]', 'closed', pht('Closed'), in_array('closed', $statuses)));
}
示例14: buildSearchForm
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
{
$author_phids = $saved_query->getParameter('authorPHIDs', array());
$answerer_phids = $saved_query->getParameter('answererPHIDs', array());
$status = $saved_query->getParameter('status', PonderQuestionStatus::STATUS_OPEN);
$form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('answerers')->setLabel(pht('Answered By'))->setValue($answerer_phids))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(PonderQuestionStatus::getQuestionStatusMap()));
}
示例15: render
public function render()
{
$question = $this->question;
$viewer = $this->getViewer();
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$viewer->getPHID()])) {
$view = 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.'));
return phutil_tag_div('ponder-add-answer-view', $view);
}
$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;
$header = id(new PHUIHeaderView())->setHeader(pht('New Answer'))->addClass('ponder-add-answer-header');
$form = new AphrontFormView();
$form->setViewer($viewer)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setViewer($viewer))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
if (!$viewer->isLoggedIn()) {
$login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/Q' . $question->getID());
$form = id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Answer'))->setHref((string) $login_href));
}
$box = id(new PHUIObjectBoxView())->appendChild($form)->setHeaderText('Answer')->addClass('ponder-add-answer-view');
if ($info_panel) {
$box->setInfoView($info_panel);
}
return array($header, $box);
}