add "view this albums comments" for each album in

mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Sun, 2004-05-02 23:43
floridave wrote:
If you look on your page your album called upload does not have any comments. So it does not have a link to the comments page.
Or do you mean you want to have a page with just comments? If so there is a great mod called stats.php. It will allow you to have comments sorted in order as well as most comments etc...

- Sorry, I wasn't too much clear :)
I know that the script only shows the link when the main album have comments inside but if a top level album has some second level albums
now the script shows also those sub-albums without any comment and not only those with comments. Check my Ma&La album; when you click on [View comments] you can see ALL the album listed, also those with 0 comments.
I know that this hack is a simple code manipulation that make public an admin function (seeing the comments) that wasn't build for users.
However it will be nice if a user can click on the vies comments link and seeing ONLY the sub albums containig commented photos.

- And now i have another question about this hack; how can i make the hack to work also with sub-albums? It'd be nice if the script shows a [View comments] link also for the sub albums. Is it possible?

- I have the beautiful stats.php mod installed, it works and i love it. It has a very good function for listing the comments but it's a little different from what i'm "asking" here.

floridave wrote:
I don't have many hidden albums so I will have to experiment. But the mod only shows the link if the user can view the album if (!$gallery->user->canReadAlbum($gallery->album)) { Can you explain a bit more. You could change the code to say logged in if you wish.

No, the script shows ALL the sub-albums, those with comments, those without comments, those public, those hidden.
Have a look at [View comments]
Here the first sub-album "Privè" is hidden (only some users can watch its pics) but you can see it listed. You can't access it but you can see that it exists (same problem with the SEARCH engine). I just want to completely hide it, not telling people (without access to its content) that i have a hidden album ;)

I know that i'm not so clear but my scholar english sucks, so plz be patient with me ;)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-05-03 01:28
mcgrelio wrote:
However it will be nice if a user can click on the vies comments link and seeing ONLY the sub albums containig commented photos.

I agree. So we would have to look at /view_comments.php to only show albums that the user can see. But we are going down a path that might not end.
This mod started out as a simple mod to show a link. We want to Keep It Simple.
You could change view_comments.php to have a check to see if the user can view the album....

mcgrelio wrote:
And now i have another question about this hack; how can i make the hack to work also with sub-albums? It'd be nice if the script shows a [View comments] link also for the sub albums. Is it possible?

Sure, just make the mod to view_album.php just like you did to albums.php.

mcgrelio wrote:
Here the first sub-album "Privè" is hidden (only some users can watch its pics) but you can see it listed. You can't access it but you can see that it exists (same problem with the SEARCH engine). I just want to completely hide it, not telling people (without access to its content) that i have a hidden album

You will have to mod view_comments.php to archive what you want.
I am not going to code it for you but you will have to look at the code and where it does the loop though, do a check for if you have permissions to view comments for the album. Use something like if ($gallery->user->canViewComments($gallery->album)) {in the loop and you should be able to exclude the ones that the users cant view the comments for.

Hope this helps.

Dave

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-05-03 02:52

mcgrelio, you said "I have the beautiful stats.php mod installed, it works and i love it. It has a very good function for listing the comments but it's a little different from what i'm "asking" here."

It would be a LOT better (more easy) to just have the links go to stats.php?type=comments&album=Album04 not view_comments.php?set_albumName=Album04 Just add those links to albums.php and view_album.php.

Then stats.php will take care of the permissions. Then you would not have to change view_comments.php to only show albums that the user has permissions for.
Why reinvent the wheel? Stats.php is more customizable with columns etc anyway.

Dave

 
mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Mon, 2004-05-03 09:54
floridave wrote:
It would be a LOT better (more easy) to just have the links go to stats.php?type=comments&album=Album04 not view_comments.php?set_albumName=Album04 Just add those links to albums.php and view_album.php.

Ok Dave, you've opened my mind :)
I always used stats.php to make static and manual queries on my photos; now you're telling me that i can modify albums.php to make a call to stats dinamical;
I think that the call should be something like:
stats.php?type=comments&album=$albumName
where $albumName is the php variable, but is this the right syntax? I don't think so.
At the moment i'm watching the albums.php code to understand wich lines to hack (i'm not a programmer), just not to have the "pie baked" ;)
I have the ViewCommentsMOD installed in a,bums.php and i think i should hack these line to achieve my purpouse so that i can use the total comments counter too.

if($gallery->app->comments_enabled == 'yes') {
	$lastCommentDate = $gallery->album->lastCommentDate();
	print lastCommentString($lastCommentDate, $displayCommentLegend);

// MOD View this album comments with stats.php
	if (lastCommentString($lastCommentDate, $displayCommentLegend ) != ""){
   		print
            " <a href=".
        	 makeGalleryUrl("view_comments.php", array("set_albumName" => $tmpAlbumName)).
         	"> [View comments] </a>".
         	"  Total comments: " .
         	$gallery->album->commentRecursiveCount()."</font>";  // add the comment counter
      	}
// MOD MOD View this album comments with stats.php

I thing of changing the makeGalleryUrl into:

makeGalleryUrl("stats.php?type=comments&album=$albumName").
"> [View comments] </a>".

but i'm quite sure that it doesn't work :(
Any ideas?

And after that i must hack the view_album.php file.... Arghhhhhh!!!! :(
Thx a lot!

 
khsjr1970

Joined: 2004-04-24
Posts: 271
Posted: Mon, 2004-05-03 14:46

Does this work on 1.4.3 as well ?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-05-03 17:17

khsjr1970, Yes...Read the pages 3-4.

mcgrelio, I finely have you thinking in the right direction!

In the ORIGINAL albums.php find

  print lastCommentString($lastCommentDate, $displayCommentLegend); 

Replace with:

  if (lastCommentString($lastCommentDate, $displayCommentLegend ) != ""){ 
   print 
        " <a href=". 
        makeGalleryUrl("stats.php", array("album" => $tmpAlbumName, "type" => "comments")). 
         "> <font color=\"ff0000\">[</font>View<font color=\"ff0000\">]</font></a>". 
         "  Total: " . "<font color=\"ff0000\">". 
         $gallery->album->commentRecursiveCount()."</font>";  // add the comment counter 
      }

Get rid of the font color if you wish and/or add a css class.

FYI if you can add more to the array to get stats to display what you want like columns etc. Just add , "argument" => "value" substitute argument and value for what stats will allow: ie: showVotes for the argument and 1 for the value.

Dave

 
mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Mon, 2004-05-03 22:42
floridave wrote:
mcgrelio, I finely have you thinking in the right direction!

Yes, thx, as I told you you've opened my mind!
Now I'm trying to hack the view_album.php but here the code isdifferent and the lines used in albums.php don't work.
I put the code after these lines:

<?php echo _("Changed: ") ?><?php echo $myAlbum->getLastModificationDate() ?>.  <br>
<?php echo _("Contains: ") ?><?php echo pluralize_n(array_sum($myAlbum->numVisibleItems($gallery->user)), _("1 item"), _("items"), _("0 items")) ?>.
<?php 
$lastCommentDate = $myAlbum->lastCommentDate();
if ($lastCommentDate > 0) {
print lastCommentString($lastCommentDate, $displayCommentLegend);
} ?><br>

The code I've added is:

<?php
// MOD View this album's comments with stats.php
  if (lastCommentString($lastCommentDate, $displayCommentLegend ) != ""){
   print
        " <a href=".
        makeGalleryUrl("stats.php", array("album" => $myAlbum, "type" => "comments")).
         "> <font color=\"ff0000\">[</font>View<font color=\"ff0000\">]</font></a>".
         "  Total: " . "<font color=\"ff0000\">".
         $gallery->album->commentRecursiveCount()."</font>";  // add the comment counter
  }
// MOD View this album's comments with stats.php 
?> <br>

The hack doesn't work because the passed variable $myAlbum isn't the right one, i've tried something else but I don't know what to pass to the function...
I know i'm a disaster...
However, thx for having baked the pie for me;)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-05-03 22:51

Not tested but try replacing
$myAlbum
with
$gallery->session->albumName

Dave

 
mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Mon, 2004-05-03 23:18
floridave wrote:
Not tested but try replacing
$myAlbum
with
$gallery->session->albumName

Dave

Nope, with that variable i can only show the main father album comments :(
like in the main page.

however thx for the ultra-fast answer!!! :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2004-05-03 23:39

try
$gallery->album->getAlbumName($index)
or
$gallery->album->getAlbumName($i)

This should work: <a href="<?php echo makeGalleryUrl('stats.php', array('album' => $gallery->album->getAlbumName($i), 'type' => 'comments')) ?>">[View comments]</a>

 
mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Tue, 2004-05-04 18:22

Ok, again, thx a lot!
Your code works and i have integrated in the if statement adding the counter code.
My final code is:

<?php
// MOD View this album's comments with stats.php
if (lastCommentString($lastCommentDate, $displayCommentLegend ) != ""){
	print
	" <a href=".
	makeGalleryUrl("stats.php", array('album' => $gallery->album->getAlbumName($i), 'type' => 'comments')).
	"> [View comments]</a><br>".
	" Total: " .
	$myAlbum->commentRecursiveCount()."<br>"; 
}
// MOD View this album's comments with stats.php
?>

I think i should write down a little tutorial about this hack, collecting your answers. Where should i post it? Here or in the stats.php thread?
You were great Dave, thanks a lot!
Cya ;)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-05-04 19:04

I think a new thread as it is a bit different than both. Both the threads are bit LONG and hard to read for a newbe. But mention the thread in both as well. I look forward to the mini tutorial.

Dave

 
mcgrelio
mcgrelio's picture

Joined: 2003-02-03
Posts: 52
Posted: Tue, 2004-05-04 22:13
floridave wrote:
I think a new thread as it is a bit different than both. Both the threads are bit LONG and hard to read for a newbe. But mention the thread in both as well. I look forward to the mini tutorial.

Dave

Ok Dave, i've wrote the mini-tutorial for inserting a [View comments] link next to each album (sub-album) letting to watch that album comments (according to the album permissions). The MOD also add a counter showing the total count of comments for the album and nested albums.
This MOD use the stats.php MOD.
You can find it HERE.
Hope it helps to newbies like me ;)

This is yours Dave ;)
Thanks a lot for your help !!