Haplo - I have done a diff between my 1.73 and 1.73b and there are a lot of changes - especially with code being moved around which makes it difficult to see what you've really changed and added. What makes it even more difficult is that after 1.73 I have done a major cleanup myself moving code around and added some new stuff - I haven't released it yet but will be doing sometime soon when I'm reasonably happy it's right.
The random photos stuff I was thinking of doing is the same as Hollis did in his example - ie a window full of random photos. I know there are already other scripts that show one random photo so I'm not sure what benefit there is in making stats.php do that.
I intend to support text under photos as well as multi columns too as there does seem to be many people who prefer that. The way you centre the photo and keep the text to the left looks really odd on my site so I won't be going with that. I will make the changes to the GALLERY_BASEDIR and init.php require provided they don't break old versions of Gallery.
I'm not sure how best to go forward with this. I will add some of your ideas into stats.php if you still want me to but I might not have the time to do everything given all the other ideas floating round that people want. Forking the code is possible but not ideal. If we do fork then it's probably best to use different names and start a new thread. To be honest I much prefer to work together for the good of everyone.
The other concern I have is to keep the code maintainable. There are lots of things that I'm thinking of adding now which could involve special cases in the code - something I prefer to minimise. If I'm not careful then stats.php will quickly become difficult to maintain.
As a heads up - I've just run your latest 1.73d and get a Parse error: parse error, unexpected T_STRING in .../stats.php on line 50
Jenny - sounds like a possibility and shouldn't be too difficult - I will add it to the list...
vaporinc - the PHP limits look ok (80MB memory, 120 sec execution time). Can you talk to your ISP and find out what limit stats.php is exceeding if indeed it is. I might be able to do something about it if I knew what it was. I suspect in Shoobee's... case his ISP has some other program running that monitors scripts and terminates anything that exceeds a certain resource limit. It could be that your ISP is doing something similar.
Cheers, Jeremy
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-04-09 10:18
Haplo - just read your last post. Thanks for the heads up about stats2.php... I didn't know about that. Ideally we need to keep this all together in one script. The Gallery dev team did contact me a few weeks ago about getting stats.php officially in 1.4.4. I replied but have heard nothing since.
Maybe I should have written stats.php in an obfuscated (unmaintainable) way then no one else could have modded it! ;)
Cheers, Jeremy
Haplo
Joined: 2004-03-29
Posts: 82
Posted: Fri, 2004-04-09 10:36
lol...maybe you should have ;)
i see your points, and am glad you're improving your great script even further!!
grap what you like for your main stats.php mod...and i will keep on suggesting addons for it but not "release" them...ok? ...but maybe i will update my current zip for a while with bugfixes...until you're released final mod with all features...ok?
im mainly interested in doing a usable toplist block for mx-portal anyway
main concern is still:
- cache (if needed for topratings)
- albums with no photos
- making ratings usable...with average ratings toplist
note: i collected all functions in one place...thats the big "moving around" of your code...since i hate functions placed all over he place ;)
btw, fixed typo on line 50
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-04-09 10:58
Haplo - I agree that having functions all over the place is not how it should be and that's one of the things that I've fixed in the next version.
Your ideas about how we develop stats.php further sound good. Any ideas are appreciated and if you can give me the code that's easy to add to stats.php then that would be great.
One thing that would be really helpful is to do a function that makes sense of the current Gallery ranking system and calculate a score for a specified image. There's already code (maybe in util.php) that is used for displaying rankings but it's not been written so that you can specify a photo and get a score back. Once we have that function then integrating voting into stats.php is trivial and you will have your toplist.
BTW I'm seriously thinking of releasing my "simplified" voting code in a usable form as a Gallery patch and adding a voting link to stats.php. You could then use stats.php to display a top 10 or whatever. My site is already running stats.php with the voting link. However this doesn't help anyone already using the standard Gallery voting.
have you talked to the gallery core guys about how they plan to develope ratings/votes for gallery in the future...maybe your simplified alternative is sufficient...at least i think so ;)
vaporinc
Joined: 2004-04-01
Posts: 13
Posted: Fri, 2004-04-09 18:41
Jeremy;
Quote:
vaporinc - the PHP limits look ok (80MB memory, 120 sec execution time). Can you talk to your ISP and find out what limit stats.php is exceeding if indeed it is. I might be able to do something about it if I knew what it was. I suspect in Shoobee's... case his ISP has some other program running that monitors scripts and terminates anything that exceeds a certain resource limit. It could be that your ISP is doing something similar.
Cheers, Jeremy
I contacted my ISP and they said nothing seamed to be wrong with the script or the resources. Then I checked the site to find that stats.php and search.php both magically work now. Thanks for your help.
Troy
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-04-09 19:26
Troy - glad to hear it's working now. Sounds like your ISP has changed / fixed something as it wasn't working earlier when I posted my reply. It would be really good to find out what they did as that could solve Shoobee's problems if he's still round here.
Haplo - I haven't spoken to the dev team about ratings / voting. The first posting that I made that talked about stats.php was really about voting. It was called "Simplified Voting Hack". At that time I was very new round here and I didn't feel in a position to be talking to the dev team about how voting should work. I did have some hope that maybe someone from the dev team would see my site and include the simplified voting in Gallery. There is a feature request on sourceforge here that is intended for voting discussions although it's very quiet over there.
well, i added topratings the cruel way, i.e. not the most efficient code ;)
during the album loop, i use the function (based on code in util.php)
// Get rating average value for all pics in statsalbum
function getRatingAverage()
{
global $statsAlbum;
$results=array();
$ratings=array();
$results_count=array();
$nv_pairs=$statsAlbum->getVoteNVPairs();
$buf='';
$voters=array();
foreach ($statsAlbum->fields["votes"] as $element => $image_votes)
{
$accum_votes=0;
$count=0;
foreach ($image_votes as $voter => $vote_value )
{
$voters[$voter]=true;
if ($vote_value> $statsAlbum->getPollScale()) // scale has changed
{
$vote_value=$statsAlbum->getPollScale();
}
$accum_votes+=$nv_pairs[$vote_value]["value"];
$count++;
}
if ($accum_votes > 0)
{
$results_count[$element]=$count;
if ($statsAlbum->getPollType() == "rank" || $statsAlbum->getPollScale() == 1)
{
$results[$element]=$accum_votes;
}
else
{
$results[$element]=number_format(((double)$accum_votes)/$count, 2);
}
}
else
{
$results[$element] = 0;
}
$index = $statsAlbum->getIndexByVotingId($element);
$ratings[$index] = array('average' => $results[$element], 'count' => $count);
}
return $ratings;
}
to get the average rating and number of counts for every image...the rest is done as for sorting date/comments etc...
uploaded in above zip...ver. 1.73e
the showVotes switch now shows (for example):
Ratings: 4.75 (6 votes)
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-04-09 20:15
Thanks Haplo - that's really cool... I will definitely get the new function into the next version of stats.php.
Cheers, Jeremy
vaporinc
Joined: 2004-04-01
Posts: 13
Posted: Fri, 2004-04-09 21:54
Jeremy,
They doubled the memory limit for the gallery subdomain.
~~ Troy
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Sat, 2004-04-10 22:54
I've just released a new version of stats.php (1.80) which is available here You can see it working on my site
Stats now includes several new features:
1) my own voting code as patches for classes/Album.php and classes/AlbumItem.php - so for those who asked about $showVotes and why it didn't work, you can now try it yourself. The patch changes are very straightforward but please backup both your album and gallery directories before patching just to be safe. Checkout the readme for details. There's also an option to get stats.php to show a voting link. ($showAddVote). When you click on one of the vote links it briefly opens vote.php - This script was hacked together and could look better but it does the job for now...BTW if you don't want to use the voting, then there's no need to patch. stats will still work for views, upload date, etc.
2) thanks largely to Haplo, stats can now show images with top ratings. It calculates the average rating for each image. This has the slight drawback in that an image with one "Excellent" vote (5.0) will typically be rated above other images with many more votes. Maybe I need to do the sort based on count as discussed previously. Thoughts/preferences anyone? You also should be aware that because of the way Gallery handles voting, this code will be slow on a site with lots of images. You can see a demo of ratings working here
3) I noticed that someone had moved the [add comment] link on their site. Personally I wasn't that keen with it under the comments as it looked out of place. Anyway after trying lots of options - none of which I was 100% happy with - I decided to support a choice. It still defaults to having the link under the comments but the position can now be controlled using a new variable $addLinksPos.
4) thanks again to Haplo you can now display the album owner using $showAlbumOwner. This is off be default.
Full details of the new functionality can be found in the readme. There are some other minor changes but they shouldn't effect functionality.
This has the slight drawback in that an image with one "Excellent" vote (5.0) will typically be rated above other images with many more votes.
A quick solution would be to only show pictures who have been voted for XX times.
~ Troy
Haplo
Joined: 2004-03-29
Posts: 82
Posted: Sun, 2004-04-11 07:22
agree with jeremy...a cut off variable should to the job
myriagon:
nice job with the new stats version
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Mon, 2004-04-12 13:17
I've now added the cutoff variable, $votesNeededToShowRating. This defaults to 5 votes which should make the rating score fair. You might want to set this lower if you only have a few votes on your site. Turn it off by setting:$votesNeededToShowRating = 0
I've also done the random images code, use: stats.php?type=random
You can limit the number of random images, for example if you want 3, then use: stats.php?type=random&ppp=3
Grid mode is switched on using the url parameter sgr=1 or you can hard code it on in stats.php. See the readme for more details. I've also added parameters to control if the captions, album links and descriptions are displayed or not.
At the moment everything is left aligned in grid mode. It looked better that way especially with lots of text below the image. I could centre align by specifying a switch if necessary although I don't support that yet.
How do i add the "Add Vote" To the each picture in my album?
floridave
Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2004-04-16 04:43
I really like the new mods I thing this is what most people are looking for. I love the customization.
The only draw back that I can see is that it does not look good with skins. Perhaps some additional classes are needed with the multi column layout:
The image name table cell is now limited to the width of the text. It is had to explain so here is a example: http://langleycom.com/g1/stats.php?type=date the gray of the title use to cover the width of the table as on the albums.php page.
In config.php there is some vaiables set for different frames:
$gallery->app->default["album_frame"] = "notebook";
$gallery->app->default["thumb_frame"] = "dots";
$gallery->app->default["image_frame"] = "shadows";
These variables can be overwritten and different for each album.
So as a suggestion if the type is random specify a frame style. That would make the if movie issue go away as well.
That leads to the size of the images when type is random.....
Should we specify a size in stats? Should we scale the images to the smallest? Leave it the way that it is and make the admin change the size of his thumbs?
I would suggest that the size of the image should default to the size of the highlight as in the config.php $gallery->app->highlight_size = "XXX"; (When the type=random) or be Yet Another URL Variable :wink:
I think this mod is the best out there. myriagon keep up the GREAT work!
Dave
floridave
Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2004-04-16 05:53
DarkunderdoG,
There is a few ways you can do this and myriagon might have a better way but this it how I did it:
in util.php add this
I added it at the end, above require (dirname(__FILE__) . '/lib/lang.php'); but that is for version 4.3.4RC3. Just above the closing php tag should be fine.
Then in view_photo.php I added this code to the caption
I gave you some code around for context. I am sure there is a few ways to do it and I am open for better ways. I have not looked at view_albums.php to see if it will go, but I am sure you can experiment.
The above code could be moved to below the caption or above as well up to you.
Dave
PS perhaps the moderator might want to move this to the voting thread that myriagon has as well: Simplified Voting Hack Or does myriagon watch that as well?
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-04-16 07:37
Hey Dave,
I've changed the caption code to behave as before in the latest version of stats (1.91) For the previous version I removed a class="mod_title" from the caption code to make it look "right". Although it looked fine with my minimalistic skin, it doesn't work with other skins. I'm still not happy with how captions are displayed in grid mode though. Maybe as you say I need to use a different class or classes. I'll try class="modcaption" which is what view_album uses when I get back from my weekend away.
I'll have a think about your other points too when I have more time.
Thanks for the compliment - much appreciated. You do a great job yourself answering peoples question.
Thanks for posting that simple vote hack. It looks fine to me. My code was more complex because I have it linked into Gallery's code to select the different types of voting - something that in retrospect isn't strictly necessary.
Cheers, Jeremy
BTW I must do some more of those great URL Variables... ;)
Terje-
Joined: 2004-01-20
Posts: 90
Posted: Fri, 2004-04-16 12:41
myriagon
This is a really good improvement to Gallery, it should be included in 1.4.4.
What's the best way to integrate it into the UI of gallery do you think?
I'm using your stats since version 1.7 and have suggestions for the next version:
1. localizing the text (so that one can choose between the different languages)
2. not only pics but also last (most viewed, etc.) albums can be shown (like my you can see here.
And one more thing: with version 1.91 I am not able to show the votes from gallery's ranking - any idea?
I like how it gives a number by the picture and the pics are really close together. Maybe you guys could enable that sort of option. Thx!
One more thing that would be cool is to have a #1 section.
This section has #1 viewed pic, #1 voted pic, #1 ranked pic, Latest picture, Latest coment, and a random picture all on one page. That would be slick. Please make my wish come true :P
vaporinc
Joined: 2004-04-01
Posts: 13
Posted: Fri, 2004-04-16 18:26
floridave,
Diffent topic, how did you get the plug-ins for the video files to work. Do you have a link to the forum that talks about it?
Thanks,
Troy
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Sun, 2004-04-18 20:05
Thanks for all the suggestions. I've now:
1. fixed the issue with ratings.
2. Modified the code to use the modcaption class when displaying multiple columns
3. Centred the text in multi column mode.
The new version (1.92) is available here I'm still not 100% happy with the look when displaying multiple columns, particularly when showing comments, but it's lots better than it was.
tmothy if you want the images closer together then try specifying more columns. Use the url variable cols= to increase the number of columns. I'll have a think about your other ideas.
terge Integrating stats in a way that looks right is difficult - particularly if the standard Gallery format is kept. Having said that I like the way that floridave has integrated stats - see http://langleycom.com/g1/albums.php Links could also be added alongside the slideshow and login links but that might be too many links.
floridave I haven't forgotten about your comments - I'll try to deal with them next.
Question, how do i change the defult thumbnail size just for the stats php not Global. Cause right now they are way too big i'd like to make them smaller. And I can't seem to hack it right.
floridave
Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-04-19 23:28
tmothy,
Jeremy is working on this. The sizes for the thumbs are the size of the thumbs in each album. If you have different thumbs settings for different albums then you will get different sizes. See my post http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=70604#70604
The problem is it is not a one line change.
If your site is small you can change the thumbs to the size you want and stats will then have the size you want. If your site is big then look for myresize here: http://www.beckettmw.com/downloads/ you will have to change isAlbumname to isAlbum.
Like I said Jeremy is working on this.
Dave
tmothy
Joined: 2004-03-06
Posts: 53
Posted: Tue, 2004-04-20 00:51
Hey thanks for the quick reply Dave. If you check out my site www.gallerymania.tk and scroll down to the "latest 5 uploaded" you will see that the 5 thumbnails are very large and I think this may be a problem from lower resolution computers. Would the only solution to resize them be a global thumbnail change? Oh and one more thing, if you click on the latest 5 from front page you will see it link into the iframe. Is there an easy fix to make it go target=_top or do I need to hack alot of code. Thx!
floridave
Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-04-20 01:30
tmothy,
Please start another thread for your issue.
Dave
InsjaHH
Joined: 2004-04-20
Posts: 4
Posted: Tue, 2004-04-20 19:36
Hai,
First of all, thank you for sharing this incredible nice plugin for Gallery; you've done a nice job creating and updating your script.
I finally registered on these forums after wandering a while, reading, searching all the time, because I've got a question about this most viewed hack. (Btw, I'm also that guy who e-mailed you earlier today because I thought I couldn't register. Since I think that perhaps someone here could also help me out, I'm posting my question here also).
What I'm trying to achieve is the following. I've got several "main" albums, my personal albums and the ones of my friends. Let me build a tree-structure here:
- Gallery
- - Friends (Others)
- - Personal (My own photo's, but no photo's in THIS particular album, only in the sub-albums)
- - - Sub-album 01
- - - Sub-album 02
- - - Sub-album xx etc.
- - Friend (Who makes lot of pictures, also only photo's in the sub-albums)
- - - Sub-album 01
- - - Sub-album 02
- - - Sub-album xx etc.
- - Other categories
So I wanted to make this script search for the most viewed photo's in the entire "Personal"-album, so that means all the sub-albums, but since it doesn't contain any photo's it gives me an PHP error: it only contains sub-albums.
Now I've stats.php?type=views&album=Personal&total=4 and also with debug=1 and it gave me the same conclusion: it can't find any photo's, so it returns a "not-an-array"-error. The reason that I can't just let the script search in my entire gallery is that I don't want any friends pictures displayed.
I hope this makes some sense, if it's not clear or something, I'm happy to clarify / explain it more thoroughly.
At present stats.php only looks at the album you specify. It does not look at nested albums of the album specified.
Perhaps Jeremy will add multi album / nested album functionality.
Yes exactly. I was hoping to get the most viewed photo's from all the sub-albums; so that it's like an "best viewed"-section of only my photo's for example. Now I only get the best viewed of 1 specific album, like your link shows me.
I hope that Jeremy could implement this functionality, or someone who could help us out writing this piece of the script.
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Wed, 2004-04-21 11:45
InsjaHH - What you're asking isn't too difficult. I have already written some code that counted the number of photos in all sub-albums. I posted that code on here some time ago. Using some of that code it will be straightforward to support what you want. At the moment I'm very busy with "real" work but when I get some time I will implement it.
Regards,
Jeremy
InsjaHH
Joined: 2004-04-20
Posts: 4
Posted: Wed, 2004-04-21 12:51
Ah wow, thanks for the quick reply! .
I see, that's wonderful news; you said you've posted the code already, did you mean in this topic? If so, I could try to implent the code while you're still busy with "real" work and still searching for some time extra for this feature.
When you see the time for it, please post the written code here or release a newer version of your incredible script.
Thanks inadvance,
Herwin.
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Thu, 2004-04-22 20:20
InsjaHH - this thread is the one that I was talking about. The idea is to use getParentAlbumNames() to check if the album is a subalbum of the one specified by the url.
Hopefully this weekend I'll have time to add the code myself.
Regards,
Jeremy
InsjaHH
Joined: 2004-04-20
Posts: 4
Posted: Fri, 2004-04-23 10:50
myriagon,
Thanks for the link, I'll try to get it working with my *low* skills of PHP. I assume you mean just adding those lines of codes to the pages classes/Album.php and albums.php and I'm done? Oh well, I'll try to test some things out anyways.
[Edit]Never mind, I'll just wait for you to find some time for it . Because it needs some more codes and stuff. Since I'm a not to good PHP scripter...[/Edit]
I hope you find some time this weekend, though don't forget to enjoy the nice weather (at least, it's going to be "fine" in the Netherlands). I would be very grateful if you could implent this feature, as many people will / would be I guess.
Thanks again for the all help you're already given me,
Herwin.
midkiff
Joined: 2003-06-27
Posts: 70
Posted: Fri, 2004-04-23 13:35
Has anyone got this to work with gallery 1.4.3 yet? I had someone elses stats script working with 1.4.2, but I can't seem to get this one to work with 1.4.3, I am getting this error: Parse error: parse error in /home/mydamnpa/public_html/gallery/stats.php on line 739
When trying to use the command: stats.php?type=date&period=6
Can you verify that your albums are all upgraded? I just went to one (miss last call) and it requried upgrading.
Log on as admin and go to the top of your Gallery and look for an [upgrade] link.
and make sure that it says that all albums are upgraded. Don't know any other ideas other than to delete stats.php and upload again.
Dave
midkiff
Joined: 2003-06-27
Posts: 70
Posted: Fri, 2004-04-23 15:39
floridave wrote:
Can you verify that your albums are all upgraded? I just went to one (miss last call) and it requried upgrading.
Log on as admin and go to the top of your Gallery and look for an [upgrade] link.
As you know, I created a stripped down version of your stats.php script in order to generate (rather than an album layout page) purely linked thumbnails, in order to call the latest images into other pages on my site via SSI. In other words, in lieu of all the embedded/not-embedded HTML and page layout code, I left only the bits that called the thumbnails and linked them to the image page.
Unfortunately, the recent upgrade of Gallery killed my hack of your hack... and looking at your update hack, I don't think I'll ever get lucky twice and figure out how to re-do what I did the first time.
Specifically, on my site, where I used to get tiny little thumbnails flowing into the page wherever I put the SSI code, I now get the error:
Fatal error: Call to undefined function: isalbumname() in /public_html/gallery/include.php on line 77
Where 'include.php' is what I called my reworked stats.php. You can get the whole thing here:
As far as I can tell, that area around line 77 is a version check, and the bump up in Gallery's version is calling something else that's not there. I don't suppose you can imagine there being a quick fix to this? I know my stats.php-to-SSI type implementation was downloaded and used by a few other folks here.
If there's no fixing what broke, any chance you could add to stats.php a "thumbnails only" output (i.e. just a href and img tags!) that can then be called via includes?
Thanks for a great hack! Clearly this kind of glitch is what separates boobs like me from pros like you.
myriagon
Joined: 2004-01-22
Posts: 130
Posted: Sun, 2004-04-25 08:37
ryanozawa - thanks for the compliment. I think you did a great job with your hack of my hack. The reason why it no longer works is not your fault. Unfortunately the underlying api in the latest version of Gallery was changed. It broke stats.php too. I added some code to fix stats a while back and I've just added the same fix to your code which should hopefully fix your issue. It appears to work ok for me. You can find the patched version here
Regards,
Jeremy
ryanozawa
Joined: 2003-10-23
Posts: 25
Posted: Sun, 2004-04-25 08:47
Wow, Jeremy. You're out of this world. Incredible! Just like that, my includes are all working again. A million thanks!
tmothy
Joined: 2004-03-06
Posts: 53
Posted: Sun, 2004-04-25 09:36
ryanozawa check out your script in action www.gallerymania.tk thx for the priv msg
You can now specify the frame style to use for the thumbs using the control variable $frameStyle. This can be any of the standard frame styles supported by Gallery such as 'dots', 'solid', 'shadows' etc. If this is not defined then the album's thumb frame style is used.
The image thumb size can be specified using the $thumbSize variable. This specifies the size in pixels. If 'default' is specified, then the Gallery default thumb size is used. This variable can be overridden by the url variable, $tsz.
For InsjaHH I have added a $showNestedAlbums control variable. If the url $album variable is specified to display only images from an album, then by setting $showNestedAlbums to 1, all images in the nested albums will also be shown.
There's a new version of stats (1.94) - second today...! - available here The latest version adds support for filtering images based on their capture date. So for instance if you want stats to display a random selection of images taken in March 2004 then use:
stats.php?type=random&ty=2004&tm=3
where ty - time year, tm - time month, td - time date
Any combination of ty, tm and td can be used. You can even get stats to display all images taken on the 14th of all months by using:
stats.php?type=cdate&td=14
There's more details in the readme. This feature was requested by Jenny so thanks for the idea - it's really cool.
Posts: 130
Haplo - I have done a diff between my 1.73 and 1.73b and there are a lot of changes - especially with code being moved around which makes it difficult to see what you've really changed and added. What makes it even more difficult is that after 1.73 I have done a major cleanup myself moving code around and added some new stuff - I haven't released it yet but will be doing sometime soon when I'm reasonably happy it's right.
The random photos stuff I was thinking of doing is the same as Hollis did in his example - ie a window full of random photos. I know there are already other scripts that show one random photo so I'm not sure what benefit there is in making stats.php do that.
I intend to support text under photos as well as multi columns too as there does seem to be many people who prefer that. The way you centre the photo and keep the text to the left looks really odd on my site so I won't be going with that. I will make the changes to the GALLERY_BASEDIR and init.php require provided they don't break old versions of Gallery.
I'm not sure how best to go forward with this. I will add some of your ideas into stats.php if you still want me to but I might not have the time to do everything given all the other ideas floating round that people want. Forking the code is possible but not ideal. If we do fork then it's probably best to use different names and start a new thread. To be honest I much prefer to work together for the good of everyone.
The other concern I have is to keep the code maintainable. There are lots of things that I'm thinking of adding now which could involve special cases in the code - something I prefer to minimise. If I'm not careful then stats.php will quickly become difficult to maintain.
As a heads up - I've just run your latest 1.73d and get a Parse error: parse error, unexpected T_STRING in .../stats.php on line 50
Jenny - sounds like a possibility and shouldn't be too difficult - I will add it to the list...
vaporinc - the PHP limits look ok (80MB memory, 120 sec execution time). Can you talk to your ISP and find out what limit stats.php is exceeding if indeed it is. I might be able to do something about it if I knew what it was. I suspect in Shoobee's... case his ISP has some other program running that monitors scripts and terminates anything that exceeds a certain resource limit. It could be that your ISP is doing something similar.
Cheers, Jeremy
Posts: 130
Haplo - just read your last post. Thanks for the heads up about stats2.php... I didn't know about that. Ideally we need to keep this all together in one script. The Gallery dev team did contact me a few weeks ago about getting stats.php officially in 1.4.4. I replied but have heard nothing since.
Maybe I should have written stats.php in an obfuscated (unmaintainable) way then no one else could have modded it! ;)
Cheers, Jeremy
Posts: 82
lol...maybe you should have ;)
i see your points, and am glad you're improving your great script even further!!
grap what you like for your main stats.php mod...and i will keep on suggesting addons for it but not "release" them...ok? ...but maybe i will update my current zip for a while with bugfixes...until you're released final mod with all features...ok?
im mainly interested in doing a usable toplist block for mx-portal anyway
main concern is still:
- cache (if needed for topratings)
- albums with no photos
- making ratings usable...with average ratings toplist
note: i collected all functions in one place...thats the big "moving around" of your code...since i hate functions placed all over he place ;)
btw, fixed typo on line 50
Posts: 130
Haplo - I agree that having functions all over the place is not how it should be and that's one of the things that I've fixed in the next version.
Your ideas about how we develop stats.php further sound good. Any ideas are appreciated and if you can give me the code that's easy to add to stats.php then that would be great.
One thing that would be really helpful is to do a function that makes sense of the current Gallery ranking system and calculate a score for a specified image. There's already code (maybe in util.php) that is used for displaying rankings but it's not been written so that you can specify a photo and get a score back. Once we have that function then integrating voting into stats.php is trivial and you will have your toplist.
BTW I'm seriously thinking of releasing my "simplified" voting code in a usable form as a Gallery patch and adding a voting link to stats.php. You could then use stats.php to display a top 10 or whatever. My site is already running stats.php with the voting link. However this doesn't help anyone already using the standard Gallery voting.
Cheers, Jeremy
www.tearoom.me.uk
Posts: 82
have you talked to the gallery core guys about how they plan to develope ratings/votes for gallery in the future...maybe your simplified alternative is sufficient...at least i think so ;)
Posts: 13
Jeremy;
I contacted my ISP and they said nothing seamed to be wrong with the script or the resources. Then I checked the site to find that stats.php and search.php both magically work now. Thanks for your help.
Troy
Posts: 130
Troy - glad to hear it's working now. Sounds like your ISP has changed / fixed something as it wasn't working earlier when I posted my reply. It would be really good to find out what they did as that could solve Shoobee's problems if he's still round here.
Haplo - I haven't spoken to the dev team about ratings / voting. The first posting that I made that talked about stats.php was really about voting. It was called "Simplified Voting Hack". At that time I was very new round here and I didn't feel in a position to be talking to the dev team about how voting should work. I did have some hope that maybe someone from the dev team would see my site and include the simplified voting in Gallery. There is a feature request on sourceforge here that is intended for voting discussions although it's very quiet over there.
Cheers, Jeremy
www.tearoom.me.uk
Posts: 82
well, i added topratings the cruel way, i.e. not the most efficient code ;)
during the album loop, i use the function (based on code in util.php)
to get the average rating and number of counts for every image...the rest is done as for sorting date/comments etc...
uploaded in above zip...ver. 1.73e
the showVotes switch now shows (for example):
Ratings: 4.75 (6 votes)
Posts: 130
Thanks Haplo - that's really cool... I will definitely get the new function into the next version of stats.php.
Cheers, Jeremy
Posts: 13
Jeremy,
They doubled the memory limit for the gallery subdomain.
~~ Troy
Posts: 130
I've just released a new version of stats.php (1.80) which is available here You can see it working on my site
Stats now includes several new features:
1) my own voting code as patches for classes/Album.php and classes/AlbumItem.php - so for those who asked about $showVotes and why it didn't work, you can now try it yourself. The patch changes are very straightforward but please backup both your album and gallery directories before patching just to be safe. Checkout the readme for details. There's also an option to get stats.php to show a voting link. ($showAddVote). When you click on one of the vote links it briefly opens vote.php - This script was hacked together and could look better but it does the job for now...BTW if you don't want to use the voting, then there's no need to patch. stats will still work for views, upload date, etc.
2) thanks largely to Haplo, stats can now show images with top ratings. It calculates the average rating for each image. This has the slight drawback in that an image with one "Excellent" vote (5.0) will typically be rated above other images with many more votes. Maybe I need to do the sort based on count as discussed previously. Thoughts/preferences anyone? You also should be aware that because of the way Gallery handles voting, this code will be slow on a site with lots of images. You can see a demo of ratings working here
3) I noticed that someone had moved the [add comment] link on their site. Personally I wasn't that keen with it under the comments as it looked out of place. Anyway after trying lots of options - none of which I was 100% happy with - I decided to support a choice. It still defaults to having the link under the comments but the position can now be controlled using a new variable $addLinksPos.
4) thanks again to Haplo you can now display the album owner using $showAlbumOwner. This is off be default.
Full details of the new functionality can be found in the readme. There are some other minor changes but they shouldn't effect functionality.
Regards, J
www.tearoom.me.uk[/]
[/]
[/]
[/]
Posts: 13
Jeremy,
I like the changes.
A quick solution would be to only show pictures who have been voted for XX times.
~ Troy
Posts: 82
agree with jeremy...a cut off variable should to the job
myriagon:
nice job with the new stats version
Posts: 130
I've now added the cutoff variable, $votesNeededToShowRating. This defaults to 5 votes which should make the rating score fair. You might want to set this lower if you only have a few votes on your site. Turn it off by setting:
$votesNeededToShowRating = 0
I've also done the random images code, use:
stats.php?type=random
You can limit the number of random images, for example if you want 3, then use:
stats.php?type=random&ppp=3
The new version (1.81) can be found here
Regards, J
www.tearoom.me.uk
Posts: 130
After several requests stats can now display rows and columns in "grid" mode like view_album.php The text is displayed below the image.
For a demo see the random page on my website.
Grid mode is switched on using the url parameter sgr=1 or you can hard code it on in stats.php. See the readme for more details. I've also added parameters to control if the captions, album links and descriptions are displayed or not.
At the moment everything is left aligned in grid mode. It looked better that way especially with lots of text below the image. I could centre align by specifying a switch if necessary although I don't support that yet.
The new version 1.90 can be found here
Regards, J
www.tearoom.me.uk
Posts: 58
How do i add the "Add Vote" To the each picture in my album?
Posts: 27300
I really like the new mods I thing this is what most people are looking for. I love the customization.
The only draw back that I can see is that it does not look good with skins. Perhaps some additional classes are needed with the multi column layout:
The image name table cell is now limited to the width of the text. It is had to explain so here is a example:
http://langleycom.com/g1/stats.php?type=date the gray of the title use to cover the width of the table as on the albums.php page.
Now that images are being called from multiple albums there is multiple frames as well example:
http://langleycom.com/g1/stats.php?type=votes&sgr=1&rows=2&sac=0&sav=0&sco=0&svi=0&svo=0&sal=0&sud=0&sde=0 I think that there should be a setting to take the albums frames IF the albums are the same album ( not random ).
In config.php there is some vaiables set for different frames:
$gallery->app->default["album_frame"] = "notebook";
$gallery->app->default["thumb_frame"] = "dots";
$gallery->app->default["image_frame"] = "shadows";
These variables can be overwritten and different for each album.
So as a suggestion if the type is random specify a frame style. That would make the if movie issue go away as well.
That leads to the size of the images when type is random.....
Should we specify a size in stats? Should we scale the images to the smallest? Leave it the way that it is and make the admin change the size of his thumbs?
I would suggest that the size of the image should default to the size of the highlight as in the config.php $gallery->app->highlight_size = "XXX"; (When the type=random) or be Yet Another URL Variable :wink:
I think this mod is the best out there. myriagon keep up the GREAT work!
Dave
Posts: 27300
DarkunderdoG,
There is a few ways you can do this and myriagon might have a better way but this it how I did it:
in util.php add this
I added it at the end, above require (dirname(__FILE__) . '/lib/lang.php'); but that is for version 4.3.4RC3. Just above the closing php tag should be fine.
Then in view_photo.php I added this code to the caption
I gave you some code around for context. I am sure there is a few ways to do it and I am open for better ways. I have not looked at view_albums.php to see if it will go, but I am sure you can experiment.
The above code could be moved to below the caption or above as well up to you.
Dave
PS perhaps the moderator might want to move this to the voting thread that myriagon has as well:
Simplified Voting Hack Or does myriagon watch that as well?
Posts: 130
Hey Dave,
I've changed the caption code to behave as before in the latest version of stats (1.91) For the previous version I removed a class="mod_title" from the caption code to make it look "right". Although it looked fine with my minimalistic skin, it doesn't work with other skins. I'm still not happy with how captions are displayed in grid mode though. Maybe as you say I need to use a different class or classes. I'll try class="modcaption" which is what view_album uses when I get back from my weekend away.
I'll have a think about your other points too when I have more time.
Thanks for the compliment - much appreciated. You do a great job yourself answering peoples question.
Thanks for posting that simple vote hack. It looks fine to me. My code was more complex because I have it linked into Gallery's code to select the different types of voting - something that in retrospect isn't strictly necessary.
Cheers, Jeremy
BTW I must do some more of those great URL Variables... ;)
Posts: 90
myriagon
This is a really good improvement to Gallery, it should be included in 1.4.4.
What's the best way to integrate it into the UI of gallery do you think?
Terje
Posts: 24
Hi myriagon,
I'm using your stats since version 1.7 and have suggestions for the next version:
1. localizing the text (so that one can choose between the different languages)
2. not only pics but also last (most viewed, etc.) albums can be shown (like my you can see here.
And one more thing: with version 1.91 I am not able to show the votes from gallery's ranking - any idea?
greetz RaVen
Posts: 53
Great work I think it would be cool to get it to emulate the other latest php script
http://www.lumiere.net/~clock/cgi-bin/gallery/view_top.php
I like how it gives a number by the picture and the pics are really close together. Maybe you guys could enable that sort of option. Thx!
One more thing that would be cool is to have a #1 section.
This section has #1 viewed pic, #1 voted pic, #1 ranked pic, Latest picture, Latest coment, and a random picture all on one page. That would be slick. Please make my wish come true :P
Posts: 13
floridave,
Diffent topic, how did you get the plug-ins for the video files to work. Do you have a link to the forum that talks about it?
Thanks,
Troy
Posts: 130
Thanks for all the suggestions. I've now:
1. fixed the issue with ratings.
2. Modified the code to use the modcaption class when displaying multiple columns
3. Centred the text in multi column mode.
The new version (1.92) is available here I'm still not 100% happy with the look when displaying multiple columns, particularly when showing comments, but it's lots better than it was.
tmothy if you want the images closer together then try specifying more columns. Use the url variable cols= to increase the number of columns. I'll have a think about your other ideas.
terge Integrating stats in a way that looks right is difficult - particularly if the standard Gallery format is kept. Having said that I like the way that floridave has integrated stats - see
http://langleycom.com/g1/albums.php Links could also be added alongside the slideshow and login links but that might be too many links.
floridave I haven't forgotten about your comments - I'll try to deal with them next.
Regards,
Jeremy
www.tearoom.me.uk
Posts: 53
Question, how do i change the defult thumbnail size just for the stats php not Global. Cause right now they are way too big i'd like to make them smaller. And I can't seem to hack it right.
Posts: 27300
tmothy,
Jeremy is working on this. The sizes for the thumbs are the size of the thumbs in each album. If you have different thumbs settings for different albums then you will get different sizes. See my post http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=70604#70604
The problem is it is not a one line change.
If your site is small you can change the thumbs to the size you want and stats will then have the size you want. If your site is big then look for myresize here: http://www.beckettmw.com/downloads/ you will have to change isAlbumname to isAlbum.
Like I said Jeremy is working on this.
Dave
Posts: 53
Hey thanks for the quick reply Dave. If you check out my site www.gallerymania.tk and scroll down to the "latest 5 uploaded" you will see that the 5 thumbnails are very large and I think this may be a problem from lower resolution computers. Would the only solution to resize them be a global thumbnail change? Oh and one more thing, if you click on the latest 5 from front page you will see it link into the iframe. Is there an easy fix to make it go target=_top or do I need to hack alot of code. Thx!
Posts: 27300
tmothy,
Please start another thread for your issue.
Dave
Posts: 4
Hai,
First of all, thank you for sharing this incredible nice plugin for Gallery; you've done a nice job creating and updating your script.
I finally registered on these forums after wandering a while, reading, searching all the time, because I've got a question about this most viewed hack. (Btw, I'm also that guy who e-mailed you earlier today because I thought I couldn't register. Since I think that perhaps someone here could also help me out, I'm posting my question here also).
What I'm trying to achieve is the following. I've got several "main" albums, my personal albums and the ones of my friends. Let me build a tree-structure here:
- Gallery
- - Friends (Others)
- - Personal (My own photo's, but no photo's in THIS particular album, only in the sub-albums)
- - - Sub-album 01
- - - Sub-album 02
- - - Sub-album xx etc.
- - Friend (Who makes lot of pictures, also only photo's in the sub-albums)
- - - Sub-album 01
- - - Sub-album 02
- - - Sub-album xx etc.
- - Other categories
So I wanted to make this script search for the most viewed photo's in the entire "Personal"-album, so that means all the sub-albums, but since it doesn't contain any photo's it gives me an PHP error: it only contains sub-albums.
Now I've stats.php?type=views&album=Personal&total=4 and also with debug=1 and it gave me the same conclusion: it can't find any photo's, so it returns a "not-an-array"-error. The reason that I can't just let the script search in my entire gallery is that I don't want any friends pictures displayed.
I hope this makes some sense, if it's not clear or something, I'm happy to clarify / explain it more thoroughly.
Herwin.
P.S: if you want to see an example for yourself, visit this website: http://pg.wels.nu/ or http://pg.wels.nu/stats.php?type=views&album=FRPE&total=4. Some other album names are e.g. FRPE_Herwin, FRPE_Marcel etc.
Posts: 27300
At present stats.php only looks at the album you specify. It does not look at nested albums of the album specified.
Perhaps Jeremy will add multi album / nested album functionality.
So you will need to do is http://pg.wels.nu/stats.php?type=views&album=FRPE_Marcel_0001
Dave
Posts: 4
Yes exactly. I was hoping to get the most viewed photo's from all the sub-albums; so that it's like an "best viewed"-section of only my photo's for example. Now I only get the best viewed of 1 specific album, like your link shows me.
I hope that Jeremy could implement this functionality, or someone who could help us out writing this piece of the script.
Posts: 130
InsjaHH - What you're asking isn't too difficult. I have already written some code that counted the number of photos in all sub-albums. I posted that code on here some time ago. Using some of that code it will be straightforward to support what you want. At the moment I'm very busy with "real" work but when I get some time I will implement it.
Regards,
Jeremy
Posts: 4
Ah wow, thanks for the quick reply! .
I see, that's wonderful news; you said you've posted the code already, did you mean in this topic? If so, I could try to implent the code while you're still busy with "real" work and still searching for some time extra for this feature.
When you see the time for it, please post the written code here or release a newer version of your incredible script.
Thanks inadvance,
Herwin.
Posts: 130
InsjaHH - this thread is the one that I was talking about. The idea is to use getParentAlbumNames() to check if the album is a subalbum of the one specified by the url.
Hopefully this weekend I'll have time to add the code myself.
Regards,
Jeremy
Posts: 4
myriagon,
Thanks for the link, I'll try to get it working with my *low* skills of PHP. I assume you mean just adding those lines of codes to the pages classes/Album.php and albums.php and I'm done? Oh well, I'll try to test some things out anyways.
[Edit]Never mind, I'll just wait for you to find some time for it . Because it needs some more codes and stuff. Since I'm a not to good PHP scripter...[/Edit]
I hope you find some time this weekend, though don't forget to enjoy the nice weather (at least, it's going to be "fine" in the Netherlands). I would be very grateful if you could implent this feature, as many people will / would be I guess.
Thanks again for the all help you're already given me,
Herwin.
Posts: 70
Has anyone got this to work with gallery 1.4.3 yet? I had someone elses stats script working with 1.4.2, but I can't seem to get this one to work with 1.4.3, I am getting this error: Parse error: parse error in /home/mydamnpa/public_html/gallery/stats.php on line 739
When trying to use the command: stats.php?type=date&period=6
Can someone please help, thanks!
Posts: 27300
midkiff,
@ http://www.mydamnpage.com/pics/stats.php?type=date&period=6&debug=2 you have a older version of stats.php. Try the latest first. Then you need to upgrade a couple of albums as well. Never saw the php error but,
saw lots of other things! :wink:
Dave
Posts: 70
I have the newer version of stats (V 1.92) here
http://www.mydamnpage.com/gallery
Posts: 27300
Can you verify that your albums are all upgraded? I just went to one (miss last call) and it requried upgrading.
Log on as admin and go to the top of your Gallery and look for an [upgrade] link.
Or failing that, go to:
http://your.server/gallery/upgrade_album.php
and make sure that it says that all albums are upgraded. Don't know any other ideas other than to delete stats.php and upload again.
Dave
Posts: 70
Yeah, I already upgraded them all, I just deleted and uploaded stats.php again and that seemed to correct it, thanks!
Posts: 271
I would like to implement this on in my gallery, anyone want to point me in the direction of the latest version download link please ?
Posts: 271
forgot to email notify
Posts: 130
Try here. Hope it works ok for you.
Regards,
Jeremy
www.tearoom.me.uk
Posts: 271
Yep, worked beautifully. I'm using 1.4.3 final.
Posts: 25
Jeremy!
As you know, I created a stripped down version of your stats.php script in order to generate (rather than an album layout page) purely linked thumbnails, in order to call the latest images into other pages on my site via SSI. In other words, in lieu of all the embedded/not-embedded HTML and page layout code, I left only the bits that called the thumbnails and linked them to the image page.
Unfortunately, the recent upgrade of Gallery killed my hack of your hack... and looking at your update hack, I don't think I'll ever get lucky twice and figure out how to re-do what I did the first time.
Specifically, on my site, where I used to get tiny little thumbnails flowing into the page wherever I put the SSI code, I now get the error:
Fatal error: Call to undefined function: isalbumname() in /public_html/gallery/include.php on line 77
Where 'include.php' is what I called my reworked stats.php. You can get the whole thing here:
http://www.leahi.net/include.zip
As far as I can tell, that area around line 77 is a version check, and the bump up in Gallery's version is calling something else that's not there. I don't suppose you can imagine there being a quick fix to this? I know my stats.php-to-SSI type implementation was downloaded and used by a few other folks here.
If there's no fixing what broke, any chance you could add to stats.php a "thumbnails only" output (i.e. just a href and img tags!) that can then be called via includes?
Thanks for a great hack! Clearly this kind of glitch is what separates boobs like me from pros like you.
Posts: 130
ryanozawa - thanks for the compliment. I think you did a great job with your hack of my hack. The reason why it no longer works is not your fault. Unfortunately the underlying api in the latest version of Gallery was changed. It broke stats.php too. I added some code to fix stats a while back and I've just added the same fix to your code which should hopefully fix your issue. It appears to work ok for me. You can find the patched version here
Regards,
Jeremy
Posts: 25
Wow, Jeremy. You're out of this world. Incredible! Just like that, my includes are all working again. A million thanks!
Posts: 53
ryanozawa check out your script in action www.gallerymania.tk thx for the priv msg
Posts: 130
There's a new version of stats (1.93) here
You can now specify the frame style to use for the thumbs using the control variable $frameStyle. This can be any of the standard frame styles supported by Gallery such as 'dots', 'solid', 'shadows' etc. If this is not defined then the album's thumb frame style is used.
The image thumb size can be specified using the $thumbSize variable. This specifies the size in pixels. If 'default' is specified, then the Gallery default thumb size is used. This variable can be overridden by the url variable, $tsz.
For InsjaHH I have added a $showNestedAlbums control variable. If the url $album variable is specified to display only images from an album, then by setting $showNestedAlbums to 1, all images in the nested albums will also be shown.
Regards,
Jeremy
www.tearoom.me.uk
Posts: 130
There's a new version of stats (1.94) - second today...! - available here The latest version adds support for filtering images based on their capture date. So for instance if you want stats to display a random selection of images taken in March 2004 then use:
stats.php?type=random&ty=2004&tm=3
where ty - time year, tm - time month, td - time date
Any combination of ty, tm and td can be used. You can even get stats to display all images taken on the 14th of all months by using:
stats.php?type=cdate&td=14
There's more details in the readme. This feature was requested by Jenny so thanks for the idea - it's really cool.
Regards,
Jeremy
www.tearoom.me.uk