// unused methods were deleted
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11795 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -213,73 +213,6 @@ class HelperCore
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a select input field
|
|
||||||
*
|
|
||||||
* @param array $values
|
|
||||||
* @param array $html_options any key => value options
|
|
||||||
* @param array $select_options
|
|
||||||
* - key: the array value that will be used as a key in my select (optional)
|
|
||||||
* - value: the array value that will be used as a label in my select (optional)
|
|
||||||
* - empty: the label displayed as an empty value (optional)
|
|
||||||
* - selected: the key corresponding to the selected value (optional)
|
|
||||||
*
|
|
||||||
* @return string html content
|
|
||||||
*/
|
|
||||||
public static function selectInput(array $values, array $html_options = array(), array $select_options = array())
|
|
||||||
{
|
|
||||||
// options management
|
|
||||||
$options = self::buildHtmlOptions($html_options);
|
|
||||||
$select_html = '<select '.$options.'>';
|
|
||||||
|
|
||||||
if (isset($select_options['key']))
|
|
||||||
$use_key = $select_options['key'];
|
|
||||||
|
|
||||||
if (isset($select_options['value']))
|
|
||||||
$use_value = $select_options['value'];
|
|
||||||
|
|
||||||
if (isset($select_options['empty']))
|
|
||||||
$select_html .= '<option value="">'.$select_options['empty'].'</option>';
|
|
||||||
|
|
||||||
if (isset($select_options['selected']) && !is_array($select_options['selected']))
|
|
||||||
$select_options['selected'] = array($select_options['selected']);
|
|
||||||
// render options fields
|
|
||||||
foreach ($values as $key => $value)
|
|
||||||
{
|
|
||||||
$current_key = isset($use_key) ? $value[$use_key] : $key;
|
|
||||||
$current_value = isset($use_value) ? $value[$use_value] : $value;
|
|
||||||
|
|
||||||
if (isset($select_options['selected']) && in_array($current_key, $select_options['selected']))
|
|
||||||
$selected = 'selected="selected"';
|
|
||||||
else
|
|
||||||
$selected = '';
|
|
||||||
|
|
||||||
$select_html .= '<option value="'.Tools::htmlentitiesUTF8($current_key).'" '.$selected.'>'.Tools::htmlentitiesUTF8($current_value).'</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$select_html .= '</select>';
|
|
||||||
return $select_html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create html a string containing html options
|
|
||||||
* eg: buildHtmlOptions(array('name' => 'myInputName', 'id' => 'myInputId'));
|
|
||||||
* return => 'name="myInputName" id="myInputId"'
|
|
||||||
*
|
|
||||||
* @param array $html_options
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected static function buildHtmlOptions(array $html_options)
|
|
||||||
{
|
|
||||||
$html = '';
|
|
||||||
|
|
||||||
foreach ($html_options as $html_option => $value)
|
|
||||||
$html .= Tools::htmlentitiesUTF8($html_option).'="'.Tools::htmlentitiesUTF8($value).'" ';
|
|
||||||
|
|
||||||
return rtrim($html, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use translations files to replace english expression.
|
* use translations files to replace english expression.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user