summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINOPIAE <inopiae@cacert.org>2013-09-14 18:08:19 +0200
committerINOPIAE <inopiae@cacert.org>2013-09-14 18:08:19 +0200
commita188b3b6a45b9ed44c571ccd079753546a2317c3 (patch)
treeb10fd63ac14783e1a7edfae4740cde22f036310e
parent2663878967145d97ab2178fbdea69a92b246aef2 (diff)
downloadcacert-devel-a188b3b6a45b9ed44c571ccd079753546a2317c3.tar.gz
cacert-devel-a188b3b6a45b9ed44c571ccd079753546a2317c3.tar.xz
cacert-devel-a188b3b6a45b9ed44c571ccd079753546a2317c3.zip
bug 988: rework of the selectbox creation
-rw-r--r--includes/notary.inc.php46
-rw-r--r--pages/wot/16.php9
-rw-r--r--pages/wot/4.php8
-rw-r--r--pages/wot/6.php2
4 files changed, 44 insertions, 21 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index 0760b14..7869ae8 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -1114,28 +1114,50 @@
return (strtotime($date)<=time()+$diff*86400);
}
+
/**
- * ttp_select()
- * fills dropdown option for TTP countrues
- * @param string $value, TRUE if the TTP CAP form is to be selected
- * @param string $selection, if selection matches option key the
+ * get_array_from_ini()
+ * gets an array from an ini file and trims all entries
+ * @param mixed $inifile, path and filename of the ini file
+ * @return
+ */
+ function get_array_from_ini($inifile){
+ $array = parse_ini_file('../config/ttp.ini');
+ ksort($array);
+ foreach($array as $key => $value)
+ {
+ unset($array[$key]);
+ $array[trim($key)] = trim($value);
+ }
+ return $array;
+ }
+
+ /**
+ * create_selectbox_HTML()
+ *
+ * @param mixed $name, name for the select element
+ * @param mixed $options, array with the data for the dropdown
+ * @param string $value, TRUE if the value for the option should be added
+ * @param string $firstline, if the should be a first line like┬┤Choose country
+ * @param string $selected, if selection matches option key the
* entry is preselected in the dropdownbox
* @return
*/
- function ttp_select($value='', $selection=''){
- $ttpcountrys = parse_ini_file('../config/ttp.ini');
- ksort($ttpcountrys);
- $return_str='';
- foreach ($ttpcountrys as $ttpcountry => $form) {
+ function create_selectbox_HTML($name, array $options, $firstline = "", $value='', $selected = ""){
+ $return_str='<select name="' . $name . '">';
+ if (!$firstline) {
+ $return_str .= '<option>' . $firstline .'</option>';
+ }
+ foreach ($options as $key => $avalue) {
$return_str.='<option ';
if (true==$value) {
- $return_str.='value="'.$form.'" ';
+ $return_str.='value="'.$avalue.'" ';
}
if ($ttpcountry==$selection){
$return_str.='selected="selected"';
}
- $return_str.=' >'.$ttpcountry.'</option>';
+ $return_str.=' >'.$key.'</option>';
}
-
+ $return_str.='</select>';
return $return_str;
}
diff --git a/pages/wot/16.php b/pages/wot/16.php
index 3f951c6..f64d1bf 100644
--- a/pages/wot/16.php
+++ b/pages/wot/16.php
@@ -112,11 +112,12 @@ $ttp_assurances_count=$num_rows = mysql_num_rows($res);
<td><input type="text" name="adress4" /></td>
</tr>
<tr>
- <td><?=_('Country where the TTP will be visted')?></td>
+ <td><?=_('Country where the TTP will be visited')?></td>
<td>
- <select size="1" name="type">
- <?echo ttp_select(TRUE)?>
- </select>
+ <?
+ $ttpcountries=get_array_from_ini('../config/ttp.ini');
+ echo create_selectbox_HTML('country',$ttpcountries, '',TRUE);
+ ?>
</td>
</tr>
<tr>
diff --git a/pages/wot/4.php b/pages/wot/4.php
index 9c30b71..954bc76 100644
--- a/pages/wot/4.php
+++ b/pages/wot/4.php
@@ -45,10 +45,10 @@ if ($_SESSION['profile']['points']<100){
<tr>
<td class="DataTD"><?=_('Country where you want to visit the TTP')?></td>
<td class="DataTD">
- <select size="1" name="country">
- <option><?=_('Choose country')?></option>
- <?echo ttp_select()?>
- </select>
+ <?
+ $ttpcountries=get_array_from_ini('../config/ttp.ini');
+ echo create_selectbox_HTML('country',$ttpcountries, _('Choose country'));
+ ?>
</td>
</tr>
<tr>
diff --git a/pages/wot/6.php b/pages/wot/6.php
index 96186af..802b85d 100644
--- a/pages/wot/6.php
+++ b/pages/wot/6.php
@@ -58,7 +58,7 @@ if(!array_key_exists('notarise',$_SESSION['_config']))
AssureFoot($id,_("I confirm this Assurance"));
if($_SESSION['profile']['ttpadmin'] >= 1) {
- ?><a href="wot.php?id=16><?=_("Show TTP details")?></a><?;
+ ?><a href="wot.php?id=16"><?=_('Show TTP details')?></a><?;
}
?>