1 |
1546
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* QuickSkin Extension options
|
4 |
|
|
* Creates HTML DropDown Option list from an array
|
5 |
|
|
*
|
6 |
|
|
* Usage Example I:
|
7 |
|
|
* Content: $template->assign('pick', array( "on", "off" ) );
|
8 |
|
|
* Template: Choose: <select name="onoff"> {options:pick} </select>
|
9 |
|
|
* Result: Choose: <select name="onoff"> <option>on</option><option>off</option> </select>
|
10 |
|
|
*
|
11 |
|
|
* Usage Example II:
|
12 |
|
|
* Content: $template->assign('color', array( "FF0000" => "Red", "00FF00" => "Green", "0000FF" => "Blue" ) );
|
13 |
|
|
* $template->assign('default', "00FF00" );
|
14 |
|
|
* Template: Color: <select name="col"> {options:color,default} </select>
|
15 |
|
|
* Result: Color: <select name="col"> <option value="FF0000">Red</option><option value="00FF00" selected>Green</option><option value="0000FF">Blue</option> </select>
|
16 |
|
|
*
|
17 |
|
|
* @author Andy Prevost andy@codeworxtech.com - original by Philipp v. Criegern philipp@criegern.de
|
18 |
|
|
*/
|
19 |
|
|
function qx_options ( $param, $default = '_DEFAULT_' ) {
|
20 |
|
|
$output = '';
|
21 |
|
|
if (is_array($param)) {
|
22 |
|
|
$keyindex = 0;
|
23 |
|
|
foreach ($param as $key => $value) {
|
24 |
|
|
if ($key==$keyindex++ && is_numeric($key)) {
|
25 |
1559
|
Luisehahne
|
$output .= '<option' . (($value == $default) ? ' selected="selected"' : '') . '>' . $value . '</option>';
|
26 |
1546
|
Luisehahne
|
} else {
|
27 |
1559
|
Luisehahne
|
$output .= '<option value="' . $key . '"' . (($key == $default) ? ' selected="selected"' : '') . '>' . $value . '</option>';
|
28 |
1546
|
Luisehahne
|
}
|
29 |
|
|
}
|
30 |
|
|
}
|
31 |
|
|
return $output;
|
32 |
|
|
}
|