Open Journal Systems  3.3.0
FormValidatorLocale.inc.php
1 <?php
2 
18  var $_requiredLocale;
19 
29  function __construct(&$form, $field, $type, $message, $requiredLocale = null, $validator = null) {
30  parent::__construct($form, $field, $type, $message, $validator);
31  if ($requiredLocale === null) $requiredLocale = AppLocale::getPrimaryLocale();
32  $this->_requiredLocale = $requiredLocale;
33  }
34 
35  //
36  // Getters and Setters
37  //
43  function getMessage() {
44  $allLocales = AppLocale::getAllLocales();
45  return parent::getMessage() . ' (' . $allLocales[$this->_requiredLocale] . ')';
46  }
47 
48  //
49  // Protected helper methods
50  //
55  function getFieldValue() {
56  $form =& $this->getForm();
57  $data = $form->getData($this->getField());
58 
59  $fieldValue = '';
60  if (is_array($data) && isset($data[$this->_requiredLocale])) {
61  $fieldValue = $data[$this->_requiredLocale];
62  if (is_scalar($fieldValue)) $fieldValue = trim((string)$fieldValue);
63  }
64  return $fieldValue;
65  }
66 }
67 
68 
PKPLocale\getAllLocales
static & getAllLocales()
Definition: PKPLocale.inc.php:537
FormValidatorLocale
Class to represent a form validation check for localized fields.
Definition: FormValidatorLocale.inc.php:16
FormValidatorLocale\__construct
__construct(&$form, $field, $type, $message, $requiredLocale=null, $validator=null)
Definition: FormValidatorLocale.inc.php:32
FormValidator\getField
getField()
Definition: FormValidator.inc.php:84
FormValidatorLocale\getMessage
getMessage()
Definition: FormValidatorLocale.inc.php:46
FormValidatorLocale\getFieldValue
getFieldValue()
Definition: FormValidatorLocale.inc.php:58
AppLocale\getPrimaryLocale
static getPrimaryLocale()
Definition: env1/MockAppLocale.inc.php:95
FormValidator\getForm
& getForm()
Definition: FormValidator.inc.php:100
FormValidator
Class to represent a form validation check.
Definition: FormValidator.inc.php:23
FormValidatorLocale\$_requiredLocale
$_requiredLocale
Definition: FormValidatorLocale.inc.php:21