qnanewquestion.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, StatusNet, Inc.
  5. *
  6. * Form for adding a new question
  7. *
  8. * PHP version 5
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category QnA
  24. * @package StatusNet
  25. * @author Zach Copley <zach@copley.name>
  26. * @copyright 2011 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. // This check helps protect against security problems;
  32. // your code file can't be executed directly from the web.
  33. exit(1);
  34. }
  35. /**
  36. * Form to add a new question
  37. *
  38. * @category QnA
  39. * @package StatusNet
  40. * @author Zach Copley <zach@copley.name>
  41. * @copyright 2011 StatusNet, Inc.
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  43. * @link http://status.net/
  44. */
  45. class QnanewquestionForm extends Form
  46. {
  47. protected $title;
  48. protected $description;
  49. /**
  50. * Construct a new question form
  51. *
  52. * @param HTMLOutputter $out output channel
  53. *
  54. * @return void
  55. */
  56. function __construct($out = null, $title = null, $description = null, $options = null)
  57. {
  58. parent::__construct($out);
  59. $this->title = $title;
  60. $this->description = $description;
  61. }
  62. /**
  63. * ID of the form
  64. *
  65. * @return int ID of the form
  66. */
  67. function id()
  68. {
  69. return 'newquestion-form';
  70. }
  71. /**
  72. * class of the form
  73. *
  74. * @return string class of the form
  75. */
  76. function formClass()
  77. {
  78. return 'form_settings ajax-notice';
  79. }
  80. /**
  81. * Action of the form
  82. *
  83. * @return string URL of the action
  84. */
  85. function action()
  86. {
  87. return common_local_url('qnanewquestion');
  88. }
  89. /**
  90. * Data elements of the form
  91. *
  92. * @return void
  93. */
  94. function formData()
  95. {
  96. $this->out->elementStart('fieldset', array('id' => 'newquestion-data'));
  97. $this->out->elementStart('ul', 'form_data');
  98. $this->li();
  99. $this->out->input(
  100. 'qna-question-title',
  101. // TRANS: Field label for a new question.
  102. _m('LABEL','Title'),
  103. $this->title,
  104. // TRANS: Field title for a new question.
  105. _m('The title of your question.'),
  106. 'title',
  107. true // HTML5 "required" attribute
  108. );
  109. $this->unli();
  110. $this->li();
  111. $this->out->textarea(
  112. 'qna-question-description',
  113. // TRANS: Field label for question details.
  114. _m('LABEL','Description'),
  115. $this->description,
  116. // TRANS: Field title for question details.
  117. _m('Your question in detail.'),
  118. 'description',
  119. true // HTML5 "required" attribute
  120. );
  121. $this->unli();
  122. $this->out->elementEnd('ul');
  123. $toWidget = new ToSelector(
  124. $this->out,
  125. common_current_user(),
  126. null
  127. );
  128. $toWidget->show();
  129. $this->out->elementEnd('fieldset');
  130. }
  131. /**
  132. * Action elements
  133. *
  134. * @return void
  135. */
  136. function formActions()
  137. {
  138. // TRANS: Button text for saving a new question.
  139. $this->out->submit('qna-question-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
  140. }
  141. }