/** * Fügt dem Feld eine Array von Werten hinzu * @param $values Array von Werten * @access protected */ function addValues($values) { rex_valid_type($values, 'array', __FILE__, __LINE__); $value = array_shift($values); $mode = ''; $group = false; if (isset($value[0]) && isset($value[1])) { $mode = 'Numeric'; if (isset($value[2]) && isset($value[3])) { $group = true; } } elseif (isset($value['label']) && isset($value['value'])) { $mode = 'Assoc'; if (isset($value['id']) && isset($value['re_id'])) { $group = true; } } elseif (is_scalar($value)) { $mode = 'Scalar'; } else { rexForm::triggerError('Unexpected Array-Structure for Array $values. Expected Keys are "0" and "1" or "label" and "value"!'); } if ($mode == 'Numeric') { // Add first Option if ($group) { $this->addValue($value[0], $value[1], $value[2], $value[3]); } else { $this->addValue($value[0], $value[1]); } // Add remaing Options foreach ($values as $value) { if ($group) { $this->addValue($value[0], $value[1], $value[2], $value[3]); } else { $this->addValue($value[0], $value[1]); } } } elseif ($mode == 'Assoc') { // Add first Option if ($group) { $this->addValue($value['label'], $value['value'], $value['id'], $value['re_id']); } else { $this->addValue($value['label'], $value['value']); } // Add remaing Options foreach ($values as $value) { if ($group) { $this->addValue($value['label'], $value['value'], $value['id'], $value['re_id']); } else { $this->addValue($value['label'], $value['value']); } } } elseif ($mode == 'Scalar') { // Add first Option $this->addValue($value, $value); // Add remaing Options foreach ($values as $value) { $this->addValue($value, $value); } } }
/** * Klassenkonstruktor */ function rexFormSection($tableName, $label, $whereParams, $columns = 1) { rex_valid_type($label, 'string', __FILE__, __LINE__); $this->label = $label; $this->columns = $columns; $this->anchor = ''; // Parentkonstruktor aufrufen $this->rexfieldController($tableName, $whereParams); }
function _interpret($fieldName, $fieldLabel, $fieldId, $fieldType, $fieldAttributes, $fieldValidators, $fieldExtras) { rex_valid_type($fieldName, 'string', __FILE__, __LINE__); rex_valid_type($fieldLabel, 'string', __FILE__, __LINE__); rex_valid_type($fieldId, 'string', __FILE__, __LINE__); rex_valid_type($fieldType, 'string', __FILE__, __LINE__); rex_valid_type($fieldAttributes, 'array', __FILE__, __LINE__); rex_valid_type($fieldValidators, 'array', __FILE__, __LINE__); rex_valid_type($fieldExtras, 'array', __FILE__, __LINE__); // Feld attribute if (count($fieldAttributes) > 0) { $attributes = $fieldAttributes; $fieldAttributes = array(); foreach ($attributes as $attr) { $parts = explode("=", $attr); $fieldAttributes[$parts[0]] = $parts[1]; } } // Feld anlegen $field = new $fieldType($fieldName, $fieldLabel, $fieldAttributes); // Valdiator hinzufügen if (count($fieldValidators) > 0) { foreach ($fieldValidators as $criteria) { $criteria = trim($criteria); if ($criteria == '') { continue; } $validator_parts = explode('|', $criteria); $field->addValidator($validator_parts[0], $validator_parts[1]); } } // Feldspezifische Extras if (count($fieldExtras) > 0) { switch ($fieldType) { case "selectField": foreach ($fieldExtras as $extra) { // wenn | drinne ist, dann nach value u. name aufspalten if (strpos($extra, '|') !== false) { $extra_parts = explode('|', $extra); $name = $extra_parts[0]; $value = $extra_parts[1]; } else { $name = $extra; $value = $extra; } $field->AddOption($name, $value); } break; } } return $field; }
/** * Setzt die Spaltenbreiten der Tabelle * * @param array Spaltenbreiten, wobei jeder index des Arrays einer Spalte entspricht * @access public */ function setColGroup($colgroup) { rex_valid_type($colgroup, 'array', __FILE__, __LINE__); $this->colgroup = $colgroup; }
/** * Schalter, um die Speicherfunktion dieses Feldes zu aktivieren/deaktvieren. * In der Grundeinstellung zeigt das readOnlyField die Werte nur an, * speichert diese beim save() aber nicht in die DB. * * @param $activate_save boolean true/false Speicherfunktion aktiviert/deaktiviert */ function activateSave($activateSave) { rex_valid_type($activateSave, array('boolean'), __FILE__, __LINE__); $this->activateSave = $activateSave; }
function rex_uninstallAddon($file, $debug = false) { rex_valid_type($file, 'file', __FILE__, __LINE__); rex_valid_type($debug, 'boolean', __FILE__, __LINE__); return _rex_installDump($file, $debug); }
/** * Prüft, ob ein Wert schon vorhanden ist * @param $value Wert des Wertes * @access protected */ function hasValue($value) { rex_valid_type($value, 'string', __FILE__, __LINE__); return array_key_exists($value, $this->getValues()); }
/** * Setzt den Trenner für die Werte * @access public */ function setValueSeparator($value_separator) { rex_valid_type($value_separator, 'string', __FILE__, __LINE__); $this->value_separator = $value_separator; }
function _formatStrftime($value, $format) { global $I18N; rex_valid_type($format, 'string', __FILE__, __LINE__); if (empty($value)) { return ''; } if ($format == '' || $format == 'dateformat') { // Default REX-Dateformat $format = $I18N->msg('dateformat'); } elseif ($format == 'datetime') { // Default REX-Datetimeformat $format = $I18N->msg('datetimeformat'); } return strftime($format, $value); }
/** * Versetzt das Formular in den Editier-Modus. * Im Editier Modus, ist ein "ÜBERNEHMEN" und "SPEICHERN" Button vorhanden. * Diese sind sonst nicht eingeblendet. */ function setEditMode($edit_mode) { rex_valid_type($edit_mode, 'boolean', __FILE__, __LINE__); $this->edit_mode = $edit_mode; }
function setButtonLabel($name, $label) { rex_valid_type($name, 'string', __FILE__, __LINE__); rex_valid_type($label, 'string', __FILE__, __LINE__); $this->buttons[$name]['label'] = $label; }
function setWhere($whereParams) { rex_valid_type($whereParams, 'array', __FILE__, __LINE__); $this->whereParams = $whereParams; }
/** * Prüft die übergebene Variable auf einen bestimmten Datentyp * * @param mixed zu überprüfende Variable * @param mixed Kriterium das geprüft werden soll * @param string Datei * @param string Zeilennummer * @return bool true wenn die Variable $var dem Type $type entspricht, sonst false * @access protected */ function _rex_check_vartype($var, $type, $file, $line) { switch ($type) { // simple-vartypes case 'boolean': return is_bool($var); case 'integer': return is_int($var); case 'double': return is_double($var); case 'float': return is_float($var); case 'scalar': return is_scalar($var); case 'numeric': return is_numeric($var); case 'string': return is_string($var); case 'array': return is_array($var); // object-types // object-types case 'NULL': case 'null': return is_null($var); case 'object': return is_object($var); case 'class': rex_valid_type($var, 'array', $file, $line); rex_valid_type($var[0], 'object', $file, $line); rex_valid_type($var[1], 'string', $file, $line); return is_a($var[0], $var[1]); case 'subclass': rex_valid_type($var, 'array', $file, $line); rex_valid_type($var[0], 'object', $file, $line); rex_valid_type($var[1], 'string', $file, $line); return is_subclass_of($var[0], $var[1]); // filesystem-types // filesystem-types case 'method': rex_valid_type($var, 'array', $file, $line); rex_valid_type($var[0], 'object', $file, $line); rex_valid_type($var[1], 'string', $file, $line); return method_exists($var[0], $var[1]); case 'file': return is_file($var); case 'dir': return is_dir($var); case 'resource': return is_resource($var); case 'upload': return is_uploaded_file($var); // attributechecks // attributechecks case 'readable': return is_readable($var); case 'writable': return is_writable($var); case 'callable': rex_valid_type($var, array('string', 'array'), $file, $line); return is_callable($var); default: return false; } }