May 24, 2013, 12:57:02 AM

Login with username, password and session length

FORUM POSTING GUIDELINES - Please read and follow them.

Pages: 1 2 [3]
  Print  
Author Topic: Decimal / currency numbers separator  (Read 1541 times)
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #30 on: March 19, 2012, 09:20:12 PM »

I am afraid I am not familiar with either of those, so I am glad you figured that out! Smiley What are you using them for and why would they care about a print_r function in a theme file which renders as html?
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #31 on: March 19, 2012, 09:34:50 PM »

The problem, probably, occurs because some jquery interaction is being blocked.

I skirted the issue in the Varnish adding the following code to the file default.vcl


Code:
sub vcl_pass {
        # Do not cache these paths.
        if (req.url ~ "^/administrator/.*$" ||
        req.url ~ "^/jreviews/listings/edit/.*$" ||
        req.url ~ "^.*/ajax/.*$" {
        return (pass);
        }
}
Logged
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #32 on: March 19, 2012, 10:07:09 PM »

 Huh
My solution is not working 100%. The system shows the same page with or without proxy, but the proxy (I don't know why) blocks the custom fields. The custom fields are in the page, but not showed. Maybe the problem is the script that formats and renders the custom fields in the page. What is this script?

Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #33 on: March 19, 2012, 10:34:54 PM »

Fields data is loaded via ajax using the fields_controller.php and processed on the browser using jreviews.fields.js
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #34 on: June 07, 2012, 01:56:03 PM »

After many tests I finaly found the problem with reverse proxy.

The problem is some kind of warning from fields_controller.php when the value $selected_values[$curr_form_field['name']][0] are empty and the code execute number_format function. This "warning" is ignored by browsers, but the proxy blocks the script when found it. So, the solution is simple: test if the variable are empty before execute number_format.

The final code for fields_controller.php is:

Code:
                   case 'decimal':
                        if($decimal_separator == ',' && !empty($selected_values[$curr_form_field['name']][0])){
                                $fields[$curr_form_field['name']]['selected'] = number_format($selected_values[$curr_form_field['name']][0], 2, ',' ,'.');
//                                $fields[$curr_form_field['name']]['selected'] = $selected_values[$curr_form_field['name']];
                        }
                        else
                                $fields[$curr_form_field['name']]['selected'] = $selected_values[$curr_form_field['name']];
                    break;
                    default:
                        $fields[$curr_form_field['name']]['selected'] = $selected_values[$curr_form_field['name']];
                    break;
Logged
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #35 on: June 29, 2012, 11:54:02 PM »

This solution is creating a problem with geomaps because lat/long needs to be in english format.

How can I detect if "Currency Format" property of decimal numbers is set to "yes" in fields_controller.php?
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #36 on: June 30, 2012, 08:11:42 AM »

The properties are inside this array $curr_form_field['options']. You need to do a print_r be able to see all the array keys.
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #37 on: July 01, 2012, 12:15:50 AM »

The properties are inside this array $curr_form_field['options']. You need to do a print_r be able to see all the array keys.

when I try to put print_r($curr_form_field['options']); into fields_controller.php the script craches and I can't see anything.

If I can detect Currency Format = yes I can apply the conversion just if this option are true.
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #38 on: July 01, 2012, 08:30:25 AM »

Look in the ajax response using Firebug. I think the setting is using the key "curr_format"
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #39 on: July 01, 2012, 09:54:13 PM »

50% of problem solved.

The final code for /controllers/fields_controller.php is

                    case 'decimal':
                        if($decimal_separator == ',' && !empty($selected_values[$curr_form_field['name']][0]) && $curr_form_field['options']['curr_format']==true){
                                          $fields[$curr_form_field['name']]['selected'] = number_format($selected_values[$curr_form_field['name']][0], 2, ',' ,'.');
                        }
                        else
                                $fields[$curr_form_field['name']]['selected'] = $selected_values[$curr_form_field['name']];
                    break;



now the problem is /models/field.php

I need to identify the same variable to do the correct change. I tried the change bellow, but isn't working.

                        case 'decimal':
                                $inputValue = Sanitize::getString($data['Field'][$fieldLocation],$fieldName);
                                                        $inputValue = $inputValue == '' ? null : $inputValue;
//                                if($decimal_separator == ',' && $field['Field']['_params']['curr_format']==true){
                                if($decimal_separator == ','){
                                        $inputValue = str_replace(".", "", $inputValue);
                                        $inputValue = str_replace(",", ".", $inputValue);
                                }
                        break;
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #40 on: July 02, 2012, 06:09:55 AM »

The settings for the field are not needed there and therefore are not available. You are going to have to use the exact field name, $fieldName, as the check to make your changes/
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Julio Sene França
Full Member
***
Offline Offline

Posts: 71


WWW
« Reply #41 on: July 02, 2012, 10:27:38 PM »

Well, this isn't an elegant (and trustable) solution.
Let's change the way to solve this problem.
How can I change the function that add the lat long coordenates to put values using coma and not poit?  Where is the file to change geomaps.mapPopupSimple()?
Logged
Alejandro
Global Moderator
Administrator
Hero Member
*
Offline Offline

Posts: 28411


« Reply #42 on: July 03, 2012, 06:56:30 AM »

It is in geomaps.js. If I am not mistaken the values come straight from the Google Maps API.
Logged

http://www.reviewsforjoomla.com/testimonials Leave a testimonial for JReviews
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!