@anonymous-piwik-user opened this issue on June 13th 2008

I have embedded Piwik to my PHP site and I'm calling Piwik from PHP code directly.

In the code Piwik checks whether file exists:

function Piwik_getFlagFromCode($code)
    $path = 'plugins/UserCountry/flags/%s.png';
    $normalPath = sprintf($path,$code);
    // flags not in the package !
        return sprintf($path, 'xx');            
    return $normalPath;

The PHP file where I'm calling Piwik locates in different folder. Really flag file exists but this function can't locate it and returns 'xx' value.

I have solved this problem just by commenting IF section. But you have to invent something to make it more intelligent.

Thanks, Anton Andriyevskyy Keywords: flag flags country countries

@robocoder commented on December 31st 2008

Attachment: updated patch 254.patch

@robocoder commented on January 14th 2009

Attachment: test file testing.php

@robocoder commented on January 14th 2009

Attachment: UserCountry.test.php

@robocoder commented on January 17th 2009

Attachment: Patch against svn functions.diff

@robocoder commented on December 26th 2008

Is it as simple as changing it to use an absolute path? e.g.,

$path = dirname($_SERVER['SCRIPT_FILENAME']) . "/flags/%s.png";
@mattab commented on January 14th 2009

vipsoft, can you please confirm that you have tested the patch with the use case meglio mentionned? thanks

@robocoder commented on January 14th 2009

Yes, tested before (i.e., got "xx.png") and after (e.g., getting "us.png").

@mattab commented on January 14th 2009

vipsoft, instead of dirname(FILE) we could use PIWIK_INCLUDE_PATH right?

@robocoder commented on January 14th 2009

I was thinking there might be a corner case that failed where PIWIK_INCLUDE_PATH was a relative path, but I just tested that scenario manually and it worked correctly.

So yeah, use PIWIK_INCLUDE_PATH instead, e.g.,

        $path = PIWIK_INCLUDE_PATH . "/plugins/UserCountry/flags/%s.png";

I'll see if I can add a test case.

@mattab commented on January 14th 2009

Perfect vipsoft: it's a very good reflex to add test cases, or update existing test files. Fixed in [881]

@robocoder commented on January 17th 2009

matt: please revert this patch; I broke the flag icons on the UI where it expects Piwik_getFlagFromCode() to return a relative path to the image file

@robocoder commented on February 3rd 2009

Matt: this patch can be committed too

@robocoder commented on February 11th 2009

committed in [885]

This issue was closed on July 30th 2009
Powered by GitHub Issue Mirror