PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/pkp/classes/reviewForm/ReviewFormElement.inc.php

https://github.com/lib-uoguelph-ca/ocs
PHP | 235 lines | 93 code | 29 blank | 113 comment | 4 complexity | 1fcf7618213d50a82cf89052c1bc1ff1 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * @file classes/reviewForm/ReviewFormElement.inc.php
  4. *
  5. * Copyright (c) 2000-2012 John Willinsky
  6. * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  7. *
  8. * @class ReviewFormElement
  9. * @ingroup reviewForm
  10. * @see ReviewFormElementDAO
  11. *
  12. * @brief Basic class describing a review form element.
  13. *
  14. */
  15. define('REVIEW_FORM_ELEMENT_TYPE_SMALL_TEXT_FIELD', 0x000001);
  16. define('REVIEW_FORM_ELEMENT_TYPE_TEXT_FIELD', 0x000002);
  17. define('REVIEW_FORM_ELEMENT_TYPE_TEXTAREA', 0x000003);
  18. define('REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES', 0x000004);
  19. define('REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS', 0x000005);
  20. define('REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX', 0x000006);
  21. class ReviewFormElement extends DataObject {
  22. /**
  23. * Constructor.
  24. */
  25. function ReviewFormElement() {
  26. parent::DataObject();
  27. }
  28. /**
  29. * Get localized question.
  30. * @return string
  31. */
  32. function getLocalizedQuestion() {
  33. return $this->getLocalizedData('question');
  34. }
  35. /**
  36. * Get localized list of possible responses.
  37. * @return array
  38. */
  39. function getLocalizedPossibleResponses() {
  40. return $this->getLocalizedData('possibleResponses');
  41. }
  42. //
  43. // Get/set methods
  44. //
  45. /**
  46. * Get the review form ID of the review form element.
  47. * @return int
  48. */
  49. function getReviewFormId() {
  50. return $this->getData('reviewFormId');
  51. }
  52. /**
  53. * Set the review form ID of the review form element.
  54. * @param $reviewFormId int
  55. */
  56. function setReviewFormId($reviewFormId) {
  57. return $this->setData('reviewFormId', $reviewFormId);
  58. }
  59. /**
  60. * Get sequence of review form element.
  61. * @return float
  62. */
  63. function getSequence() {
  64. return $this->getData('sequence');
  65. }
  66. /**
  67. * Set sequence of review form element.
  68. * @param $sequence float
  69. */
  70. function setSequence($sequence) {
  71. return $this->setData('sequence', $sequence);
  72. }
  73. /**
  74. * Get the type of the review form element.
  75. * @return string
  76. */
  77. function getElementType() {
  78. return $this->getData('reviewFormElementType');
  79. }
  80. /**
  81. * Set the type of the review form element.
  82. * @param $reviewFormElementType string
  83. */
  84. function setElementType($reviewFormElementType) {
  85. return $this->setData('reviewFormElementType', $reviewFormElementType);
  86. }
  87. /**
  88. * get required
  89. * @return boolean
  90. */
  91. function getRequired() {
  92. return $this->getData('required');
  93. }
  94. /**
  95. * Set
  96. * @param $viewable boolean
  97. */
  98. function setRequired($required) {
  99. return $this->setData('required', $required);
  100. }
  101. /**
  102. * get included
  103. * @return boolean
  104. */
  105. function getIncluded() {
  106. return $this->getData('included');
  107. }
  108. /**
  109. * set included
  110. * @param $included boolean
  111. */
  112. function setIncluded($included) {
  113. return $this->setData('included', $included);
  114. }
  115. /**
  116. * Get question.
  117. * @param $locale string
  118. * @return string
  119. */
  120. function getQuestion($locale) {
  121. return $this->getData('question', $locale);
  122. }
  123. /**
  124. * Set question.
  125. * @param $question string
  126. * @param $locale string
  127. */
  128. function setQuestion($question, $locale) {
  129. return $this->setData('question', $question, $locale);
  130. }
  131. /**
  132. * Get possible response.
  133. * @param $locale string
  134. * @return string
  135. */
  136. function getPossibleResponses($locale) {
  137. return $this->getData('possibleResponses', $locale);
  138. }
  139. /**
  140. * Set possibleResponse.
  141. * @param $possibleResponse string
  142. * @param $locale string
  143. */
  144. function setPossibleResponses($possibleResponses, $locale) {
  145. return $this->setData('possibleResponses', $possibleResponses, $locale);
  146. }
  147. /**
  148. * Get an associative array matching review form element type codes with locale strings.
  149. * (Includes default '' => "Choose One" string.)
  150. * @return array reviewFormElementType => localeString
  151. */
  152. function &getReviewFormElementTypeOptions() {
  153. static $reviewFormElementTypeOptions = array(
  154. '' => 'manager.reviewFormElements.chooseType',
  155. REVIEW_FORM_ELEMENT_TYPE_SMALL_TEXT_FIELD => 'manager.reviewFormElements.smalltextfield',
  156. REVIEW_FORM_ELEMENT_TYPE_TEXT_FIELD => 'manager.reviewFormElements.textfield',
  157. REVIEW_FORM_ELEMENT_TYPE_TEXTAREA => 'manager.reviewFormElements.textarea',
  158. REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES => 'manager.reviewFormElements.checkboxes',
  159. REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS => 'manager.reviewFormElements.radiobuttons',
  160. REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX => 'manager.reviewFormElements.dropdownbox'
  161. );
  162. return $reviewFormElementTypeOptions;
  163. }
  164. /**
  165. * Get an array of all multiple responses element types.
  166. * @return array reviewFormElementTypes
  167. */
  168. function &getMultipleResponsesElementTypes() {
  169. static $multipleResponsesElementTypes = array(REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES, REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS, REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX);
  170. return $multipleResponsesElementTypes;
  171. }
  172. /** DEPRECATED **/
  173. /**
  174. * Get localized question.
  175. * @return string
  176. */
  177. function getReviewFormElementQuestion() {
  178. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  179. return $this->getLocalizedQuestion();
  180. }
  181. /**
  182. * Get localized list of possible responses.
  183. * @return array
  184. */
  185. function getReviewFormElementPossibleResponses() {
  186. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  187. return $this->getLocalizedPossibleResponses();
  188. }
  189. /**
  190. * Get the ID of the review form element.
  191. * @return int
  192. */
  193. function getReviewFormElementId() {
  194. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  195. return $this->getId();
  196. }
  197. /**
  198. * Set the ID of the review form element.
  199. * @param $reviewFormElementId int
  200. */
  201. function setReviewFormElementId($reviewFormElementId) {
  202. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  203. return $this->setId();
  204. }
  205. }
  206. ?>