Location of icon directory
AlexisWilke - December 31, 2008 - 21:24
| Project: | BAWStats |
| Version: | 6.x-1.0-2 |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
anaru,
When I check my awstats outside of Drupal (directly from awstats.pl), I get nice bars over my tables that show me graphically how much this and that happened on the hours, day, month... From Drupal, no such bars!
What could cause that problem?
Thank you.
Alexis

#1
Copy the "icons" from your AWStats install on your server to the "icons" folder.
Took me a while to track them down on my server as "icon" isn't mentioned, guess it depends on what your server is set up with. I found the directory at /usr/local/cpanel/base/images/awstats on Centos 5.
#2
Thanks for picking this up no_idea_yet!
I have been meaning to make this clearer in the docs for ages. I think what is needed is a README or INSTALL file in the top level directory that describes what to do. At present, the install information is in docs/install.drupal.txt, and is somewhat confusing, as it partly relates to the option of installing the source code from the better awstats project in a drupal tree, whereas now the code comes with the module. However, there is some useful stuff in there about the icons directory, that would be good to put in a README file.
I haven't time to work on this right now - but if anyone wants to help out, I would have time to review and commit a README file later this week.
#3
So far, I did not need to have it in Drupal, so it is not so bad, but I will keep this in mind. Could we not have a sub-folder named icon in the bawstats module that would work?
#4
The "icon" directory comes from the bawstats project and the "icons" directory comes from awstats. I'm reluctant to package files with the drupal module that already exist in the awstats distribution, which people will already have installed.
#5
Okay, I see why I posted this problem.
Whenever I save the settings, I get a warning telling me that /usr/share/awstats/icon is not a directory.
<?phpWarning, the AWstats icon path "/usr/share/awstats/icon" is not a directory.
?>
So I checked with an ls statement:
<?phpls -ld /usr/share/awstats/icon
drwxr-xr-x 9 root root 4096 2008-03-26 23:22 /usr/share/awstats/icon
?>
It definitively is a link... The rest of the folders seem to work just fine, so I would think that this module has a problem accessing the folder... Permissions are right (all the parents also have drwxr-xr-x).
Then I searched for the error in the bawstats.admin.inc file and I find this:
<?php$testvalue = substr($value,1);
?>
which actually removes the / at the start of the path! Thus, the error is very misleading since it tells me it cannot find a directory that perfectly exists, but you simply are not looking for that directory anyway. And on my end, I just don't see why you do that.
Okay, so as instructed, now I copy the folder. I think it is crazy to have to do that, but I'll take it that awstats is the one that does not do it properly... 8-)
Now, what I will bitch about is the error message and the default value shown in the settings:
1) The error message should show the path as used (i.e. $testvalue and not $value) and explain that the icon folder HAS to be under the Drupal environment to function properly.
2) The current default is shown as: "sites/all/modules/bawstats/icon", which is wrong, you must have a slash at the start or it fails. The correct default is: "/sites/all/modules/bawstats/icon".
Finally, if it is pretty much mandatory for the icons to be under bawstats/icon, don't let people change the path, just tell them with an error that it is missing! [not a warning] (again, I think it would make it a LOT simpler to just do it in your project and don't bother thousands in wondering about that one...)
Otherwise, it works. So no worries. 8-)
Thank you.
Alexis Wilke
#6
Thanks for your work on this Alexis and sorry (once again) for the delay in answering.
I've been thinking about this, and it would seem that the modern way to put external code such as the icons directory is to use a subdirectory of sites/all/libraries or sites//libraries; see http://drupal.org/project/libraries .
This has the advantage that if you update your module using a tarball or drush, you don't lose the icon directory.
I would propose the location for the icon directory as:
sites/all/libraries/awstats/icon
We could have
sites/all/libraries/awstats/wwwroot/icon
so that people could copy the whole awstats library to sites/all/libraries/, but I don't this this is as good, as it may encourage people to leave the cgi scripts in web space.
In any case, I agree that we shouldn't let people change the path. Hopefully this will solve all the slash woe...
Thoughts on this would be welcome.
#7
That sounds good. And the error message should say something like "You have not installed the awastats icons in folder blah". That would make it clearer...
#8
Yes, that's a good idea. I think the wysiwyg module does that, so we could look there for code.
#9
Here is a patch that makes the standard location of the icon directory sites/all/libraries/bawstats/icon . It introduces a dependency on the libraries module.
#10
That looks good to me. 8-)
Thank you!
Alexis
#11
Thanks for the speedy reply Alexis. I've now committed the patch, with a little update_N function in the install file to warn you if the libraries module isn't installed.
#12
Automatically closed -- issue fixed for 2 weeks with no activity.