[Weberp-svn] SF.net SVN: weberp:[6827] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-07-21 16:20:58
|
Revision: 6827 http://weberp.svn.sourceforge.net/weberp/?rev=6827&view=rev Author: tim_schofield Date: 2011-07-21 16:20:52 +0000 (Thu, 21 Jul 2011) Log Message: ----------- Changes to coding layout Modified Paths: -------------- trunk/Currencies.php trunk/includes/MiscFunctions.php Modified: trunk/Currencies.php =================================================================== --- trunk/Currencies.php 2011-07-21 16:20:40 UTC (rev 6826) +++ trunk/Currencies.php 2011-07-21 16:20:52 UTC (rev 6827) @@ -7,6 +7,7 @@ include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); +include('includes/CurrenciesArray.php'); if (isset($_GET['SelectedCurrency'])){ $SelectedCurrency = $_GET['SelectedCurrency']; @@ -67,12 +68,6 @@ $Errors[$i] = 'DecimalPlaces'; $i++; } - if (mb_strlen($_POST['CurrencyName']) > 20) { - $InputError = 1; - prnMsg(_('The currency name must be 20 characters or less long'),'error'); - $Errors[$i] = 'CurrencyName'; - $i++; - } if (mb_strlen($_POST['Country']) > 50) { $InputError = 1; prnMsg(_('The currency country must be 50 characters or less long'),'error'); @@ -100,7 +95,7 @@ /*SelectedCurrency could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ $sql = "UPDATE currencies SET - currency='" . $_POST['CurrencyName'] . "', + currency='" . $CurrenciesArray[$SelectedCurrency] . "', country='". $_POST['Country']. "', hundredsname='" . $_POST['HundredsName'] . "', decimalplaces='" . $_POST['DecimalPlaces'] . "', @@ -117,12 +112,13 @@ hundredsname, decimalplaces, rate) - VALUES ('" . $_POST['CurrencyName'] . "', - '" . $_POST['Abbreviation'] . "', - '" . $_POST['Country'] . "', - '" . $_POST['HundredsName'] . "', - '" . $_POST['DecimalPlaces'] . "', - '" . $_POST['ExchangeRate'] . "')"; + VALUES ('" . $CurrenciesArray[$_POST['Abbreviation']] . "', + '" . $_POST['Abbreviation'] . "', + '" . $_POST['Country'] . "', + '" . $_POST['HundredsName'] . "', + '" . $_POST['DecimalPlaces'] . "', + '" . $_POST['ExchangeRate'] . "' + )"; $msg = _('The currency definition record has been added'); } @@ -195,7 +191,7 @@ FROM currencies"; $result = DB_query($sql, $db); - echo '<table class="selection">'; + echo '<br /><table class="selection">'; echo '<tr><td></td> <th>' . _('ISO4217 Code') . '</th> <th>' . _('Currency Name') . '</th> @@ -241,7 +237,7 @@ <td class="number">%s</td> <td class="number">%s</td> <td><a href="%s&SelectedCurrency=%s">%s</a></td> - <td><a href="%s&SelectedCurrency=%sdelete=1">%s</a></td> + <td><a href="%s&SelectedCurrency=%s&delete=1">%s</a></td> <td><a href="%s/ExchangeRateTrend.php?%s">' . _('Graph') . '</a></td> </tr>', $ImageFile, @@ -333,14 +329,13 @@ if (!isset($_POST['Abbreviation'])) {$_POST['Abbreviation']='';} echo '<table class="selection"><tr> <td>' ._('Currency Abbreviation') . ':</td> - <td><input ' . (in_array('Abbreviation',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Abbreviation" value="' . $_POST['Abbreviation'] . '" size=4 maxlength=3></td></tr>'; + <td><select name="Abbreviation">'; + foreach ($CurrenciesArray as $Abbreviation=>$CurrencyName) { + echo '<option value="'.$Abbreviation.'">'.$CurrencyName.'</option>'; + } + echo '</select></td></tr>'; } - echo '<tr><td>'._('Currency Name').':</td>'; - echo '<td>'; - if (!isset($_POST['CurrencyName'])) {$_POST['CurrencyName']='';} - echo '<input ' . (in_array('CurrencyName',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="CurrencyName" size=20 maxlength=20 value="' . $_POST['CurrencyName'] . '">'; - echo '</td></tr>'; echo '<tr><td>'._('Country').':</td>'; echo '<td>'; if (!isset($_POST['Country'])) {$_POST['Country']='';} Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2011-07-21 16:20:40 UTC (rev 6826) +++ trunk/includes/MiscFunctions.php 2011-07-21 16:20:52 UTC (rev 6827) @@ -152,7 +152,7 @@ $stack = array(); foreach ($tags as $tag) { $index = count($elements); - if ($tag['type'] == 'complete' OR $tag['type'] == 'open') { + if (isset($tag['attributes']) and ($tag['type'] == 'complete' OR $tag['type'] == 'open')) { $elements[$index] = new XmlElement; $elements[$index]->name = $tag['tag']; $elements[$index]->attributes = $tag['attributes']; @@ -173,8 +173,10 @@ $Currencies = array(); - foreach ($elements[0]->children[2]->children[0]->children as $CurrencyDetails){ - $Currencies[$CurrencyDetails->attributes['currency']]= $CurrencyDetails->attributes['rate'] ; + if (isset($elements)) { + foreach ($elements[0]->children[2]->children[0]->children as $CurrencyDetails){ + $Currencies[$CurrencyDetails->attributes['currency']]= $CurrencyDetails->attributes['rate'] ; + } } $Currencies['EUR']=1; //ECB delivers no rate for Euro //return an array of the currencies and rates This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |