- let makePathfield return usable values for the formfield (dynamically changing between select, text and hidden, depending on settings)

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2011-02-24 10:50:59 +01:00
parent ca9128bdbf
commit 393a5ce570
7 changed files with 43 additions and 27 deletions

View File

@@ -42,9 +42,9 @@ return array(
), ),
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect 'select_var' => $pathSelect['value']
), ),
'url' => array( 'url' => array(
'visible' => ($settings['panel']['pathedit'] == 'Dropdown' ? true : false), 'visible' => ($settings['panel']['pathedit'] == 'Dropdown' ? true : false),

View File

@@ -42,9 +42,9 @@ return array(
), ),
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect 'select_var' => $pathSelect['value']
), ),
'url' => array( 'url' => array(
'visible' => ($settings['panel']['pathedit'] == 'Dropdown' ? true : false), 'visible' => ($settings['panel']['pathedit'] == 'Dropdown' ? true : false),

View File

@@ -26,9 +26,9 @@ return array(
'fields' => array( 'fields' => array(
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect 'select_var' => $pathSelect['value']
), ),
'options_indexes' => array( 'options_indexes' => array(
'label' => $lng['extras']['directory_browsing'], 'label' => $lng['extras']['directory_browsing'],

View File

@@ -26,9 +26,9 @@ return array(
'fields' => array( 'fields' => array(
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect 'select_var' => $pathSelect['value']
), ),
'username' => array( 'username' => array(
'label' => $lng['login']['username'], 'label' => $lng['login']['username'],

View File

@@ -36,9 +36,9 @@ return array(
), ),
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect, 'select_var' => $pathSelect['value']
), ),
'ftp_password' => array( 'ftp_password' => array(
'label' => $lng['login']['password'], 'label' => $lng['login']['password'],

View File

@@ -41,9 +41,9 @@ return array(
), ),
'path' => array( 'path' => array(
'label' => $lng['panel']['path'], 'label' => $lng['panel']['path'],
'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : NULL), 'desc' => ($settings['panel']['pathedit'] != 'Dropdown' ? $lng['panel']['pathDescription'] : null).(isset($pathSelect['note']) ? '<br />'.$pathSelect['value'] : ''),
'type' => ($settings['panel']['pathedit'] != 'Dropdown' ? 'text' : 'select'), 'type' => $pathSelect['type'],
'select_var' => $pathSelect 'select_var' => $pathSelect['value']
), ),
'ftp_password' => array( 'ftp_password' => array(
'label' => $lng['login']['password'], 'label' => $lng['login']['password'],

View File

@@ -36,11 +36,15 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '')
{ {
global $lng; global $lng;
$value = str_replace($path, '', $value); $value = str_replace($path, '', $value);
$field = ''; $field = array();
if($fieldType == 'Manual') if($fieldType == 'Manual')
{ {
$field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" />'; $field = array(
'type' => 'text',
'value' => htmlspecialchars($value)
);
} }
elseif($fieldType == 'Dropdown') elseif($fieldType == 'Dropdown')
{ {
@@ -58,7 +62,7 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '')
{ {
if(sizeof($dirList) <= 100) if(sizeof($dirList) <= 100)
{ {
$field = '<select name="path">'; $_field = '';
foreach($dirList as $key => $dir) foreach($dirList as $key => $dir)
{ {
if(strpos($dir, $path) === 0) if(strpos($dir, $path) === 0)
@@ -66,23 +70,35 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '')
$dir = makeCorrectDir(substr($dir, strlen($path))); $dir = makeCorrectDir(substr($dir, strlen($path)));
} }
$field.= makeoption($dir, $dir, $value); $_field.= makeoption($dir, $dir, $value);
} }
$field.= '</select>'; $field = array(
'type' => 'select',
'value' => $_field
);
} }
else else
{ {
// remove starting slash we added // remove starting slash we added
// for the Dropdown, #225 // for the Dropdown, #225
$value = substr($value, 1); $value = substr($value, 1);
$field = $lng['panel']['toomanydirs']; //$field = $lng['panel']['toomanydirs'];
$field.= '<br /><input type="text" name="path" value="' . htmlspecialchars($value) . '" />'; $field = array(
'type' => 'text',
'value' => htmlspecialchars($value),
'note' => $lng['panel']['toomanydirs']
);
} }
} }
else else
{ {
$field = $lng['panel']['dirsmissing']; //$field = $lng['panel']['dirsmissing'];
$field.= '<input type="hidden" name="path" value="/" />'; $field = '<input type="hidden" name="path" value="/" />';
$field = array(
'type' => 'hidden',
'value' => '/',
'note' => $lng['panel']['dirsmissing']
);
} }
} }