mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Registry is more strong
This commit is contained in:
@@ -29,7 +29,6 @@ class registry implements registryInterface
|
||||
protected static $_instance;
|
||||
|
||||
const TYPE_BOOLEAN = 'boolean';
|
||||
const TYPE_ARRAY = 'array';
|
||||
const TYPE_ENUM_MULTI = 'enum_multi';
|
||||
const TYPE_INTEGER = 'integer';
|
||||
const TYPE_ENUM = 'enum';
|
||||
@@ -105,7 +104,6 @@ class registry implements registryInterface
|
||||
$value = (int) $row['value'];
|
||||
break;
|
||||
case self::TYPE_ENUM_MULTI:
|
||||
case self::TYPE_ARRAY:
|
||||
$value = unserialize($row['value']);
|
||||
break;
|
||||
case self::TYPE_STRING:
|
||||
@@ -118,12 +116,6 @@ class registry implements registryInterface
|
||||
break;
|
||||
}
|
||||
|
||||
if ($row['type'] == self::TYPE_BINARY) {
|
||||
if (!is_executable($value)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->save($row['key'], $value);
|
||||
}
|
||||
if ($loaded === true)
|
||||
@@ -161,7 +153,6 @@ class registry implements registryInterface
|
||||
$this->load();
|
||||
|
||||
switch ($type) {
|
||||
case self::TYPE_ARRAY:
|
||||
case self::TYPE_ENUM_MULTI:
|
||||
$sql_value = serialize($value);
|
||||
$value = (array) $value;
|
||||
@@ -185,6 +176,12 @@ class registry implements registryInterface
|
||||
break;
|
||||
}
|
||||
|
||||
if ($value != '' && $type == self::TYPE_BINARY) {
|
||||
if (!is_executable($value)) {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
$conn = connection::getPDOConnection();
|
||||
|
||||
$sql = 'REPLACE INTO registry (`id`, `key`, `value`, `type`)
|
||||
|
@@ -127,7 +127,6 @@ class setup
|
||||
case registry::TYPE_INTEGER:
|
||||
case registry::TYPE_BOOLEAN:
|
||||
case registry::TYPE_STRING:
|
||||
case registry::TYPE_ARRAY:
|
||||
$type = $datas['type'];
|
||||
break;
|
||||
default:
|
||||
@@ -174,13 +173,15 @@ class setup
|
||||
}
|
||||
}
|
||||
|
||||
$type = 'string';
|
||||
$type = $variable['type'];
|
||||
switch ($variable['type']) {
|
||||
case 'string':
|
||||
case 'password':
|
||||
case \registry::TYPE_STRING:
|
||||
case \registry::TYPE_BINARY:
|
||||
case \registry::TYPE_TEXT:
|
||||
case \registry::TYPE_TIMEZONE:
|
||||
$datas[$variable['name']] = (string) trim($datas[$variable['name']]);
|
||||
break;
|
||||
case 'enum':
|
||||
case \registry::TYPE_ENUM:
|
||||
if (!isset($variable['available'])) {
|
||||
$variable['error'] = 'avalaibility';
|
||||
} elseif (!is_array($variable['available'])) {
|
||||
@@ -189,25 +190,16 @@ class setup
|
||||
$variable['error'] = 'avalaibility';
|
||||
}
|
||||
break;
|
||||
case 'enum_multi':
|
||||
case \registry::TYPE_ENUM_MULTI:
|
||||
if (!isset($datas[$variable['name']]))
|
||||
$datas[$variable['name']] = null;
|
||||
$datas[$variable['name']] = ($datas[$variable['name']]);
|
||||
$type = 'array';
|
||||
break;
|
||||
case 'boolean':
|
||||
case \registry::TYPE_BOOLEAN:
|
||||
$datas[$variable['name']] = strtolower($datas[$variable['name']]) === 'true' ? '1' : '0';
|
||||
$type = 'boolean';
|
||||
break;
|
||||
case 'integer':
|
||||
case \registry::TYPE_INTEGER:
|
||||
$datas[$variable['name']] = (int) trim($datas[$variable['name']]);
|
||||
$type = 'integer';
|
||||
break;
|
||||
case 'text':
|
||||
$datas[$variable['name']] = trim($datas[$variable['name']]);
|
||||
break;
|
||||
case 'timezone':
|
||||
$datas[$variable['name']] = trim($datas[$variable['name']]);
|
||||
break;
|
||||
default:
|
||||
$error = true;
|
||||
|
@@ -1633,7 +1633,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>type</name>
|
||||
<type>enum('string','boolean','array','integer')</type>
|
||||
<type>enum('string','boolean','array','integer','text','binary','timezone','enum_multi','enum')</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>string</default>
|
||||
|
@@ -164,19 +164,20 @@ foreach ($GV as $section) {
|
||||
|
||||
switch ($value['type']) {
|
||||
|
||||
case 'boolean':
|
||||
case \registry::TYPE_BOOLEAN:
|
||||
$input = '
|
||||
<input class="checkbox" ' . ($readonly ? 'readonly="readonly"' : '') . ' ' . ( $currentValue == '0' ? 'checked="selected"' : '' ) . ' type="radio" name="' . $value['name'] . '" value="False" id="id_' . $value['name'] . '_no" /><label for="id_' . $value['name'] . '_no">False</label>
|
||||
<input class="checkbox" ' . ($readonly ? 'readonly="readonly"' : '') . ' ' . ( $currentValue == '1' ? 'checked="checked"' : '' ) . ' type="radio" name="' . $value['name'] . '" value="True" id="id_' . $value['name'] . '_yes" /><label for="id_' . $value['name'] . '_yes">True</label>
|
||||
';
|
||||
break;
|
||||
case 'string':
|
||||
case \registry::TYPE_BINARY:
|
||||
case \registry::TYPE_STRING:
|
||||
$input = '<input ' . ($readonly ? 'readonly="readonly"' : '') . ' name="' . $value['name'] . '" id="id_' . $value['name'] . '" type="text" value="' . str_replace('"', '"', $currentValue) . '"/>';
|
||||
break;
|
||||
case 'text':
|
||||
case \registry::TYPE_TEXT:
|
||||
$input = '<textarea ' . ($readonly ? 'readonly="readonly"' : '') . ' name="' . $value['name'] . '" id="id_' . $value['name'] . '">' . str_replace('"', '"', $currentValue) . '</textarea>';
|
||||
break;
|
||||
case 'enum':
|
||||
case \registry::TYPE_ENUM:
|
||||
$input = '<select ' . ($readonly ? 'readonly="readonly"' : '') . ' name="' . $value['name'] . '" id="id_' . $value['name'] . '">';
|
||||
if (isset($value['available']) && is_array($value['available'])) {
|
||||
foreach ($value['available'] as $k => $v)
|
||||
@@ -186,7 +187,7 @@ foreach ($GV as $section) {
|
||||
}
|
||||
$input .= '</select>';
|
||||
break;
|
||||
case 'enum_multi':
|
||||
case \registry::TYPE_ENUM_MULTI:
|
||||
if (isset($value['available']) && is_array($value['available'])) {
|
||||
foreach ($value['available'] as $k => $v)
|
||||
$input .= '<input class="checkbox" type="checkbox" name="' . $value['name'] . '[]" ' . ($readonly ? 'readonly="readonly"' : '') . ' value="' . $k . '" ' . ( ( ! is_array($currentValue) || in_array($k, $currentValue)) ? 'checked="checked"' : '' ) . '/><label>' . $v . '</label><br>';
|
||||
@@ -194,16 +195,11 @@ foreach ($GV as $section) {
|
||||
echo '<p style="color:red;">erreur avec la valeur ' . $value['name'] . '</p>';
|
||||
}
|
||||
break;
|
||||
case 'list':
|
||||
|
||||
break;
|
||||
case 'integer':
|
||||
case \registry::TYPE_INTEGER:
|
||||
$input .= '<input ' . ($readonly ? 'readonly="readonly"' : '') . ' name="' . $value['name'] . '" id="id_' . $value['name'] . '" type="text" value="' . $currentValue . '"/>';
|
||||
break;
|
||||
case 'password':
|
||||
$input .= '<input ' . ($readonly ? 'readonly="readonly"' : '') . ' name="' . $value['name'] . '" id="id_' . $value['name'] . '" type="password" value="' . str_replace('"', '\"', stripslashes($currentValue)) . '"/>';
|
||||
break;
|
||||
case 'timezone':
|
||||
case \registry::TYPE_TIMEZONE:
|
||||
if (trim($currentValue) === '') {
|
||||
$datetime = new DateTime();
|
||||
$currentValue = $datetime->getTimezone()->getName();
|
||||
|
Reference in New Issue
Block a user