Exemplo n.º 1
0
 public function __construct($tag, rex_form $table = null, array $attributes = [], $separateEnding = false)
 {
     $this->value = null;
     $this->label = '';
     $this->tag = $tag;
     $this->table = $table;
     $this->setAttributes($attributes);
     $this->separateEnding = $separateEnding;
     $this->setHeader('');
     $this->setFooter('');
     $this->setPrefix('');
     $this->setSuffix('');
     $this->fieldName = '';
     $this->validator = rex_validator::factory();
 }
Exemplo n.º 2
0
 /**
  * Sets a property.
  *
  * @param string $key   Key of the property
  * @param mixed  $value Value for the property
  *
  * @return bool TRUE when an existing value was overridden, otherwise FALSE
  *
  * @throws InvalidArgumentException on invalid parameters
  */
 public static function setProperty($key, $value)
 {
     if (!is_string($key)) {
         throw new InvalidArgumentException('Expecting $key to be string, but ' . gettype($key) . ' given!');
     }
     switch ($key) {
         case 'server':
             if (!rex_validator::factory()->url($value)) {
                 throw new InvalidArgumentException('"' . $key . '" property: expecting $value to be a full URL!');
             }
             $value = rtrim($value, '/') . '/';
             break;
         case 'error_email':
             if (null !== $value && !rex_validator::factory()->email($value)) {
                 throw new InvalidArgumentException('"' . $key . '" property: expecting $value to be an email address!');
             }
             break;
     }
     $exists = isset(self::$properties[$key]);
     self::$properties[$key] = $value;
     return $exists;
 }
Exemplo n.º 3
0
$sel_be_sprache->setId('rex-id-userperm-mylang');
$sel_be_sprache->addOption('default', '');
$saveLocale = rex_i18n::getLocale();
$langs = [];
foreach (rex_i18n::getLocales() as $locale) {
    rex_i18n::setLocale($locale, false);
    // Locale nicht neu setzen
    $sel_be_sprache->addOption(rex_i18n::msg('lang'), $locale);
}
rex_i18n::setLocale($saveLocale, false);
$userperm_be_sprache = rex_request('userperm_be_sprache', 'string', $user->getLanguage());
$sel_be_sprache->setSelected($userperm_be_sprache);
// --------------------------------- FUNCTIONS
$update = rex_post('upd_profile_button', 'bool');
if ($update) {
    if ($useremail && !rex_validator::factory()->email($useremail)) {
        $error = rex_i18n::msg('invalid_email');
    }
}
if ($update && !$error) {
    $updateuser = rex_sql::factory();
    $updateuser->setTable(rex::getTablePrefix() . 'user');
    $updateuser->setWhere(['id' => $user_id]);
    $updateuser->setValue('name', $username);
    $updateuser->setValue('description', $userdesc);
    $updateuser->setValue('email', $useremail);
    $updateuser->setValue('language', $userperm_be_sprache);
    $updateuser->addGlobalUpdateFields();
    try {
        $updateuser->update();
        $success = rex_i18n::msg('user_data_updated');
Exemplo n.º 4
0
 function rex_form_element($tag, &$table, $attributes = array(), $separateEnding = false)
 {
     $this->value = null;
     $this->label = '';
     $this->tag = $tag;
     $this->table =& $table;
     $this->setAttributes($attributes);
     $this->separateEnding = $separateEnding;
     $this->setHeader('');
     $this->setFooter('');
     $this->setPrefix('');
     $this->setSuffix('');
     $this->fieldName = '';
     $this->validator = rex_validator::factory();
 }
Exemplo n.º 5
0
 public function testIsValid()
 {
     $validator = rex_validator::factory();
     $this->assertTrue($validator->isValid(''));
     $this->assertNull($validator->getMessage());
     $validator->add('notEmpty', 'not-empty');
     $validator->add('minLength', 'min-length', 3);
     $this->assertFalse($validator->isValid(''));
     $this->assertEquals('not-empty', $validator->getMessage());
     $this->assertFalse($validator->isValid('ab'));
     $this->assertEquals('min-length', $validator->getMessage());
     $this->assertTrue($validator->isValid('abc'));
     $this->assertNull($validator->getMessage());
 }