Topic Title: [TESTING] Selectable Album Random Block

Forum Index » Blocks » [TESTING] Selectable Album Random Block
Topic URL: http://www.nukedgallery.net/postt620.html

AuthorMessage
Post Title: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Wed Jan 28, 2004 10:57 am
All the same functions as the RandomBlock V2, but with the addition of the admin being able to select which albums he/she wants shown. You can grab a testing version of a selectable random block here:
http://www.nukedgallery.net/download-file-37.html

When you log into your nuke site as admin, you will be presented with a list of your albums. Check the ones you want included, and click the "Save" button. Once you've logged out as admin, you should see only photos from your chosen albums in the block. See the demo at the demo site [nukedgallery.net]. I selected to only allow photos from the "Christmas 2001" album to be chosen.

Note that when you add new albums, or new photos to existing albums, you will have to go through the admin interface and re-select the album so that the correct number of photos is stored in the cache.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
gravityarc
Joined: Aug 29, 2003
Posts: 22

Posted: Fri Jan 30, 2004 1:48 am
Hey dari. Stupid question, but how do you select the ablums? Confused I don't get prompted anywhere to select them. I KNOW I'm overlooking something dumb, but I just can't find it.

Thanks.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
sillium
Joined: Jan 27, 2004
Posts: 4

Posted: Fri Jan 30, 2004 5:40 am
After installing and trying to access "new Block" from Admin menu i get this error
Code: › Warning: fopen(/is/htdocs/XXXX/XXX/modules/Gallery/albums/block-random.cache): failed to open stream: No such file or directory in /is/htdocs/XXX/XXXXX/modules/Gallery/platform/fs_unix.php on line 55


(account nr. has been replaced by XXXX Wink )

regards
alex

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Jan 30, 2004 8:10 am
gravityarc wrote: › Hey dari. Stupid question, but how do you select the ablums? Confused I don't get prompted anywhere to select them. I KNOW I'm overlooking something dumb, but I just can't find it.

Thanks.


log into your nuke site as admin, the block should now look something like this:

Just click the ones you want Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Jan 30, 2004 8:12 am
sillium wrote: › After installing and trying to access "new Block" from Admin menu i get this error
Code: › Warning: fopen(/is/htdocs/XXXX/XXX/modules/Gallery/albums/block-random.cache): failed to open stream: No such file or directory in /is/htdocs/XXX/XXXXX/modules/Gallery/platform/fs_unix.php on line 55


(account nr. has been replaced by XXXX Wink )

regards
alex


you didn't specify your albums directory properly (it should NOT be inside your gallery installation directory). also, this block is not intended for use on PostNuke (re your other post on Newest Albums block).

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 12:35 pm
gravityarc wrote: › Hey dari. Stupid question, but how do you select the ablums? Confused I don't get prompted anywhere to select them. I KNOW I'm overlooking something dumb, but I just can't find it.

Thanks.


i'm with him, i didnt get prompted either...thought it might have been becasue one (out of 2 total) of the albums was empty, so i uploaded a pic to it and still nothing

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 12:37 pm
look two posts up..it should appear in the block when you're logged into your site as the GOD admin.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
gravityarc
Joined: Aug 29, 2003
Posts: 22

Posted: Tue Feb 24, 2004 1:13 pm
Dari- I'm not seeing the option to select the albums either. Does it need to be the ACTUAL God account or just any admin?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 1:16 pm
the check is this:
PHP: › <?php if(is_admin($admin)) ?>

and it may just eval to true if it's the GOD admin...is there another non-god admin check?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 1:23 pm
i am logged in as the God Admin, and i still dont get it...i dont see that code in any of the files i downloaded...which is it supposed to be in?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 1:37 pm
shit i must've been smoking crack the day i uploaded it....here it is:
http://www.nukedgallery.net/download-file-37.html

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 2:10 pm
I don't see this either:



when I'm logged in as admin. Also I had to remove the floatval statement to fix errors.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 2:12 pm
grab that latest file...it should be fixed...if not, i must be totally losing it.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 2:19 pm
Laughing Sry man I think you must be - I just grabbed and installed the files from the link above!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 2:21 pm
Are you sure thats the right link? I don't see any of the TEXT (The following albums are ....) from the block in the code?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 2:25 pm
lol...are you still smoking crack...i still dont get the prompt and i still dont see that code in any of the files

lol...dari's loosing it... Laughing

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 2:28 pm
WTF is going on here...AAAAAAAAAAAAAAAHHHHH.... Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad Evil or Very Mad
lemme try it one more time...i have reuploaded the CORRECT code and it still issn't showing up...checking the download link now...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 2:32 pm
OK, try it now...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 2:41 pm
umm...it might be me, but i have the correct code, but i still dont get the select optoins

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 2:45 pm
No joy with me either!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 2:47 pm
ah, add $admin to the global list up top...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 2:49 pm
ding ding ding...we have a winner Laughing

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 2:50 pm
Yep - that did it - but also now have this error:

Warning: Wrong parameter count for fgets() in /home/splash/public_html/blocks/block-NG-RandomPhotoSelectTest.php on line 80

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 2:50 pm
so does this mean that whenever we are logged in as God admin we dont see the pics in the block, but always see the choices?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 2:52 pm
irish: correct
slack: checking now...culprit is:
PHP: › <?php if($fd = @fopen(CACHE_FILE,"r")){
                while(
$line fgets($fd)) { ?>

you can create the cache and it should be ok...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 3:13 pm
hmn - getting this now:

Warning: Invalid argument supplied for foreach() in /home/splash/public_html/blocks/NG-RandomPhotoSelectTest_functions.php on line 259 Fatal error: Call to a member function on a non-object in /home/splash/public_html/blocks/NG-RandomPhotoSelectTest_functions.php on line 101

block-random.cache isn't populating - but it did previously when the old block (random) was being used

see error:

http://www.deepingsraftrace.com

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 3:19 pm
got it...i'll work on it so that if the file isn't there it doesn't crap out on people...
now you know why the thread is headlined with "TESTING" Wink

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Feb 24, 2004 3:44 pm
boom..try the new download (same link as above)...notice one extra thing you have to specify (your ALBUM_DIRECTORY)...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Feb 24, 2004 4:42 pm
Nope - tried everything - can't get it to work! The albums list comes up in admin, I can tick the ones I want, save to cache (or not as the case may be) but after log out of admin I get the same error:

Warning: Invalid argument supplied for foreach() in /home/splash/public_html/blocks/NG-RandomPhotoSelectTest_functions.php on line 259 Fatal error: Call to a member function on a non-object in /home/splash/public_html/blocks/NG-RandomPhotoSelectTest_functions.php on line 101

If I delete the cache file I get the message about creating the cache file. If I create empty cache file (tried chmod 777) still get error!

Strange cause the original random TEST block worked fine - just didn;t allow me to select albums!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Feb 24, 2004 4:46 pm
hmm, odd, i havent gotten any of those errors...works perfectly on my site ever since this
Quote: › ah, add $admin to the global list up top...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
SpecialEd
Joined: Mar 03, 2004
Posts: 28
Location: Alaska
Posted: Tue Mar 16, 2004 3:40 pm
I see this in the block and nothing else

Quote: › Please create your cache file.


how do I create a cache file?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Tue Apr 27, 2004 11:48 am
I am trying to use multiple instances of this block, each pulling from a different album...how do i need to rename/recode the three associated files to achieve this?

block-NG-RandomPhotoSelectTest.php
NG-RandomPhotoSelectTest_functions.php
block-NG-AutoPhoto.php

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
inSaNE_iRIsH
Joined: Jun 19, 2003
Posts: 101

Posted: Fri May 07, 2004 3:33 pm
bump?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Fredo
Joined: May 06, 2004
Posts: 5
Location: Paris, France
Posted: Mon May 10, 2004 9:16 am
Hi, i just tried this new random block and i get the following error message :

"ERROR: requested index [6] out of bounds [2]
Fatal error: Call to a member function on a non-object in /home/xxxx/public_html/modules/gallery/classes/Album.php on line 1064"

It's about the orientation of the picture, but i can't figure out why i get this error.

The gallery version is 1.4.3

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Mon May 10, 2004 9:22 am
Check to see if there is a file in your BLOCKS directory call block-random.cache. If there is - delete it and refresh your page that contains the block.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Fredo
Joined: May 06, 2004
Posts: 5
Location: Paris, France
Posted: Mon May 10, 2004 10:35 am
I've already tried to delete and recreate the cache file.but i still have the same error.

However when the cache file is created, only the main albums are inserted, the sub-albums aren't. Is it normal ?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Mon May 10, 2004 10:45 am
Are you using the SELECTABLE RANDOM block or the normal RANDOM block? The Normal one should build a cache file of all the albums - the selectable one, only the ones you select(I believe!).

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Fredo
Joined: May 06, 2004
Posts: 5
Location: Paris, France
Posted: Mon May 10, 2004 10:50 am
I'm using the selectable one. It creates the cache file but only with main albums.

Explanations :
My albums hierarchy is :
-Album1
- Subalbum1.1
- Subalbum1.2
-Album2
- Subalbum2.1
- Subalbum2.2
-etc...

When i check everthing only Album1 and Album1 are mentionned in the random-block.cache file, the subalbums1.1, subalbums2.2 aren't mentioned.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Mon May 10, 2004 11:14 am
BUMP this back to DARI - it's his block, I'm sure he will respond shortly Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Fredo
Joined: May 06, 2004
Posts: 5
Location: Paris, France
Posted: Mon May 10, 2004 11:57 am
After a few tries, the problem is the treatment of the subalbums. The script block-NG-RandomPhotoSelectTest.php only filled the list of albums with the name of the main albums. I will try to find out how to correct this.

Fredo

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Fredo
Joined: May 06, 2004
Posts: 5
Location: Paris, France
Posted: Tue May 11, 2004 4:32 am
To make it work with subalbums, i made the following change in NG-RandomPhotoSelectTest_functions.php :

Search the function createAdminList($albumName,$depth=0)

Replace the line :

$content .= "<input type=\"checkbox\" value=\"$photoCount\"
name=\"$albumName\">";

With

$content .= "<input type=\"checkbox\" value=\"$photoCount\"
name=\"" .$nestedAlbum->fields['name'] ."\">";

That's all.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
ashe
Joined: Mar 11, 2004
Posts: 9

Posted: Sat May 22, 2004 2:03 am
Does anyone have a working version of this block. I can not get any of it to work. All it says is
Quote: › Please create your cache file
.

There is no admin panel, no cache being created. The random photo block worked perfectly, but I would really like to use the select random photo block.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Sat May 22, 2004 12:48 pm
It's working fine here:

http://www.esp3.net

Face of ESP 04 - top right (selected from one album)

Try doing as it says - Create the cache file (I renamed the cache file in the block as it would clash with the normal random cache file if you are running both blocks)

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
siege911
Joined: Jun 09, 2004
Posts: 13

Posted: Wed Jun 09, 2004 6:07 pm
I'm getting this error.

Fatal error: Call to undefined function: isalbumname() in /home/******/*****/blocks/NG-RandomPhotoSelectTest_functions.php on line 307


I replaced certain info with ******

This error causes my site to crash as well. I only see my Left Blocks and underneath is this error. Everything in the center and the right blocks disappear.

I'm also really new at this so I'm not sure what I'm doing wrong.

I'm sure all of the "required" information is correct but I still get this error.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Thu Jun 10, 2004 12:45 am
In the block NG-RandomPhotoSelectTest_functions.php - replace ALL references to:

isalbumname()

to:

getalbumname()

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
TazM
Joined: Jun 07, 2004
Posts: 1

Posted: Mon Jun 21, 2004 12:46 am
Quote: › replace ALL references to: isalbumname() to: getalbumname()


That fixed me up and it is running really quite nicely for me now. This even after I could not get the previous block versions to work very well and/or work at all.

Thanx slackbladder for your helping the others has helped me also.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
deimos
Joined: Nov 21, 2003
Posts: 1

Posted: Sat Aug 07, 2004 10:08 am
I've been using Random Block v2 and it was working fine. I copied over the parameters to the Selectable Random Block and then made all the changes suggested in the thread and i got:

Code: › Parse error: parse error in /home/httpd/******/blocks/NG-RandomPhotoSelectTest_functions.php on line 101

Warning: Wrong parameter count for fgets() in /home/httpd/******/blocks/block-NG-RandomPhotoSelectTest.php on line 88

Fatal error: Call to undefined function: createadminlist() in /home/httpd/******/blocks/block-NG-RandomPhotoSelectTest.php on line 111


Uh, not sure went wrong here. Is there going to be an updated download so that we don't mistakes modifying code? Thanks!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
yeft
Joined: Sep 19, 2004
Posts: 4

Posted: Sun Sep 19, 2004 6:59 pm
Hey, I'm new here, but i have a question which is probably pretty easy to answer...
how do i use this random block outside of phpnuke (i like the scrolling and haven't found it anywhere else for it, but my site runs on mambo not phpnuke) and if you dont want to answer this thats cool just dont flame me cause i use mambo please

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Mon Sep 20, 2004 6:58 am
it shouldn't be too hard to modify for use outside of PHPNuke. PHPNuke uses the "return $content;" line to tell the main parser what the content of the block is. $content is populated with the HTML code throughout the block. All you'd have to do is find the equivalent return variable in Mambo and make sure everything is properly formatted.

If you wanted to use it in a static HTML page, you'd replace all of the "$content .= " with "echo ".

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
yeft
Joined: Sep 19, 2004
Posts: 4

Posted: Mon Sep 20, 2004 2:54 pm
thank you for answering!
i haven't gotten it to work ....but i'll see what i can change around

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Mon Sep 20, 2004 2:57 pm
no problem.
if i can get enough takers, i will expand this site to include more than just phpNuke. there haven't been any people w/ postnuke knowledge who have come forward yet. it would be nice to have a single point for Gallery and CMS integration...so if anyone out there reading this has knowledge in postnuke,mambo, geeklog, etc...let me know.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
yeft
Joined: Sep 19, 2004
Posts: 4

Posted: Tue Sep 21, 2004 6:18 pm
Is there an easy way just to implement this part of the code
Code: ›  else if ($selector=="RANDOM"){
   if($horozontal == 0) {
      if($scroll) {
         echo "<marquee loop=\"infinite\" direction=\"up\" behavior=\"scroll\" align=\"center\" scrollamount= \"2\" scrolldelay=\"60\" height=\"220\" onmouseover='this.stop()' onmouseout='this.start()'>";
      }
      for($i=0;$i<$number_of_pix;$i++) {
         echoget_photo(0,$scaleTo);
         if($number_of_pix >1) {
            echo "<br>";
         }
      }
      if($scroll) {
         echo"<p><p><p></marquee>";
      }
   }
   else {
      echo "<table border=\"0\"><tr>";
      for($i=0;$i<$number_of_pix;$i++) {
         echo"<td>".get_photo(0,$scaleTo)."</td>";
      }
      echo"</tr></table>";
   }
}


into the block-random.php file in gallery so when my mambo calls this it just does the scroll automatically ? the scroll is basically all i'm looking for right now, i can figure out album select later.....
thanks

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Sep 21, 2004 8:21 pm
hmm...i believe the "normal" random block does the scrolling as well, without album selection.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
yeft
Joined: Sep 19, 2004
Posts: 4

Posted: Tue Sep 21, 2004 10:01 pm
the gallery block-random i'm almost 100% positive doesnt have scrolling...if thats what your talking about
but if you were talking about the other random block V2 thing...i have used that one...but i can't get it to scroll, all i can get it to do is show a random image just as gallery's own does..

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 12:41 pm
I'm running into an issue where the block simply doens't show - no error, nothing - when I do a View Source, the code for the block just isn't there (it ends the page abrupty, as if the PHP is returning nothing to the browser and it can't continue).

I have it viewable to Admins only now as a way to test it until it's working, but it's happening for normal users when it's enabled. I do have the normal, regular Random Photo block working fine.

I'm using Nuke 7.5, Galery 1.5, and Sentinel 2.2.0, if that helps.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Apr 29, 2005 12:51 pm
try D.4. Fatal error: Call to undefined function: isalbumname() [nukedgallery.net]

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 12:56 pm
Yah - tried that, no luck.

The odd part is that there is no errror at all, just... nothing.

I'll re-enable it for all visitors, to show what I mean:

http://www.knightrealms.com/index.php

It should be on the bottom left, under Total Hits.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Apr 29, 2005 1:01 pm
you mean bottom right? Wink

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 1:02 pm
Er... yeah, that.

(Switches his gloves Wink)

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Apr 29, 2005 1:04 pm
at the top of the block file, after the opening php declaration, add:
PHP: › <?php error_reporting(E_ALL); ?>


make the block admin-viewable only, again, and post any messages.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 2:14 pm
Still no errors - same result.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
drmike
Joined: Mar 20, 2005
Posts: 229
Location: Charlotte, NC
Posted: Fri Apr 29, 2005 3:00 pm
Stats aren't showing up either.

http://www.knightrealms.com/modules.php ... s&op=Stats

-drmike

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 3:03 pm
Hmmm.... that's odd - I don't think it's related (since the page closes out, and does not end abruptly like the Block does), but it's worth noting. It's not as important to me as the Image Block, though. (We have a HUGE Gallery, and want to filter out some of the suff that just doesn't work in the block.)

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
drmike
Joined: Mar 20, 2005
Posts: 229
Location: Charlotte, NC
Posted: Fri Apr 29, 2005 3:07 pm
I'm wondering if something's corrupt in the database. Try running a REPAIR and then an OPTIMIZE on it.

The pic block is set to be visible to everybody and all that, right? I'm assuming you've checked all that already.

-drmike

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 3:10 pm
It's Admin Only for testing, since it wa ssupposed ot generate error codes - but since it's not, I can turn it back on for everyone now.

I just ran Sentinels' DB checks recently, woudl that work? Are you referring to runing the repair & optimize form Nuke's CP, or from another source such as phpMyAdmin?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
drmike
Joined: Mar 20, 2005
Posts: 229
Location: Charlotte, NC
Posted: Fri Apr 29, 2005 3:13 pm
GJSchaller wrote: › phpMyAdmin?


phpMyAdmin. The optimize you can use from PHPNuke's backend as well but I'd run a repair on it as well. Usually when blocks go missing, it's an issue with a corrupt database. At least that was what my expereince was when I modded on phpnuke.org.

*shrug* Wouldn't hurt.

-drmike

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Fri Apr 29, 2005 3:50 pm
I have the PHP fles uploaded for viewing at:

http://www.knightrealms.com/Pics/

I have the original, non-selectable ones there as well for comparison.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
drmike
Joined: Mar 20, 2005
Posts: 229
Location: Charlotte, NC
Posted: Fri Apr 29, 2005 5:10 pm
Please kindly change the extentions to .txt. Your server is trying to serve them. Smile

-drmike

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
GJSchaller
Joined: Aug 04, 2004
Posts: 37
Location: Valhalla, NY, USA
Posted: Sun May 01, 2005 6:05 pm
Done - thank you!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
whitefantom
Joined: May 05, 2005
Posts: 3

Posted: Thu May 05, 2005 11:53 pm
dari wrote: › ah, add $admin to the global list up top...


Evidently I'm just thick, because no one else seemed confused by this bit of information, but I have no idea where you mean by "up top." If you mean in the global variables listing at the top of one or more of the three files that make up the selectable block, I've done that (on all three files), and I still only see the random images when I'm logged in as Admin, not the ability to select albums. If you meant to add $admin to a global variables list somewhere else other than at the top of the block files, then I have no idea where I'm supposed to add it. Can anyone clarify?

--Jennifer

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
whitefantom
Joined: May 05, 2005
Posts: 3

Posted: Fri May 06, 2005 12:47 am
SpecialEd wrote: › I see this in the block and nothing else

Quote: › Please create your cache file.


how do I create a cache file?


Actually, I'm now having the problem above. I deleted the cache file, hoping that would help me start fresh, and now I'm getting the "Please create your cache file" message. Was the question above about how to create the cache file ever answered?

--Jennifer

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
whitefantom
Joined: May 05, 2005
Posts: 3

Posted: Fri May 06, 2005 11:19 pm
whitefantom wrote: ›
dari wrote: › ah, add $admin to the global list up top...


Evidently I'm just thick, because no one else seemed confused by this bit of information, but I have no idea where you mean by "up top." If you mean in the global variables listing at the top of one or more of the three files that make up the selectable block, I've done that (on all three files), and I still only see the random images when I'm logged in as Admin, not the ability to select albums. If you meant to add $admin to a global variables list somewhere else other than at the top of the block files, then I have no idea where I'm supposed to add it. Can anyone clarify?

--Jennifer



And now I'm back to this again. I tried simply creating a blank document and naming it block-random.cache, but doing that caused the block to crash with errors (I don't remember what the errors were at the moment, but I can easily recreate the problem and generate the errors again if necessary).

So instead of trying to manually create the file, I re-enabled the old random images block (the one without the album select option, which I had installed previous to installing the selectable version), and by displaying the old block, the cache file was re-created automatically, though with all albums present because it was generated by the old random images block. This caused the selectable images block to display images again (because it was working from the same cache file the non-selectable block had just generated), but as before, I don't get any album selection options when logged into PHPNuke as admin. All I see is the block randomly displaying images. I've added $admin to every global variables list I can find in the three files associated with this block, but it makes no difference. What am I doing--or not doing--that's preventing me from getting the album selection options, and how do I fix it?

--Jennifer

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
tpaljr
Joined: Jun 16, 2005
Posts: 10

Posted: Tue Jun 28, 2005 7:26 pm
Warning: main(public_html/blocks/block-NG-RandomPhotoSelectTest_functions.php): failed to open stream: No such file or directory in /home/xxxx/public_html/block-NG-AutoPhoto.php on line 6

Warning: main(public_html/blocks/block-NG-RandomPhotoSelectTest_functions.php): failed to open stream: No such file or directory in /home/xxxx/public_html/block-NG-AutoPhoto.php on line 6

Warning: main(): Failed opening 'public_html/blocks/block-NG-RandomPhotoSelectTest_functions.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/xxxx/public_html/block-NG-AutoPhoto.php on line 6

Fatal error: Call to undefined function: get_photo() in /home/xxxx/public_html/block-NG-AutoPhoto.php on line 18

Dari,
When in admin mode I can see the box as it was designed to do, but when I log out and login normally(non admin mode) the block where the pics suppose to be shows this error ...any ideas? I could pm you the files again if need be.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
racer25
Joined: Jul 22, 2004
Posts: 21

Posted: Tue Oct 11, 2005 2:25 am
Hi Guys,

I have the following error message in the block on the our site

Please create your cache file. - The site www.unp-df.com

Below is the code from our block I have checked the paths' with Analyzer to be sure but other than that quite puzzled.

Any ideas would be great

Using PHP 4.3.11, Nuke 7.5 Patched, Gallery 1.5

Anything else please let me know.

Thx

Code: › <?php

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Developed by Dariush Molavi at NukedGallery.net
 * Version 2.0
 * 13 December 2003
 */

 if (eregi("NG-RandomPhotoSelectTest_functions.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME, $Version_Num;

/*******************************************************************/
/* Full path to your Gallery, don't forget the trailing /          */
/*******************************************************************/
$GALLERY_BASEDIR = "/home/keller/public_html/modules/gallery/";

/*******************************************************************/
/* The module name of your Gallery, default is "gallery"           */
/*******************************************************************/
$GALLERY_MODULENAME = "gallery";

/*******************************************************************/
/* Time, in seconds, to refresh random photo cache. Default is     */
/* 86400 (check it daily)                                          */
/*******************************************************************/
define(CACHE_EXPIRED, 86400);

/*******************************************************************/
/* Full path to your albums directory, don't forget the trailing / */
/*******************************************************************/
define(ALBUM_DIRECTORY,"/home/keller/public_html/albums/");



/*******************************************************************/
/*          STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT           */
/*******************************************************************/
define(CACHE_FILE, ALBUM_DIRECTORY."block-random.cache");

$GALLERY_EMBEDDED_INSIDE = "nuke";
$GALLERY_EMBEDDED_INSIDE_TYPE = "phpnuke";

require_once($GALLERY_BASEDIR . "init.php");

function createBlockContent($album,$index,$scale,$auto=0) {
   global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;

   $id = $album->getPhotoId($index);
   $caption = $album->getCaption($index);
   $photo = $album->getPhoto($index);
   $dir = $album->getAlbumDirURL("full");
   $image = $photo->image;
   $PHOTO_URL = makeAlbumUrl($album->fields['name'], $id);
   $ALBUM_URL = makeAlbumUrl($album->fields['name']);
   if($scale == 0) {
                        if($auto == 0) {
                                $IMG = "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index)."</a><br>";
                        }
                        else {
                                $IMG = "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index)."</a><br>";
                        }
   } else {
                        if($auto == 0) {
                                $IMG = "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
                        else {
                                $IMG = "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
   }
   $FROM = "From: <a href=\"$ALBUM_URL\">" . $album->fields['title'] . '</a>';
   $blockContent .=  "\t$IMG\n";
   $blockContent .= "\t$caption<br />\n";
   $blockContent .= "\t$FROM\n</center>";
   return $blockContent;
}

function get_photo($interval, $scale,$auto=0) {
   global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;

   switch ($interval) {
      case 0:
         list($album,$index) = get_random_photo_id();
         while($album->getAlbumName($index)) {
            list($album,$index) = get_random_photo_id();
         }
         $blockContent = createBlockContent($album,$index,$scale,$auto);
         return $blockContent;
         break;
      case 1:
         if (file_exists($gallery->app->albumDir."/hourly.txt")) {
            $stat=stat($gallery->app->albumDir."/hourly.txt");
            $modtime = $stat['mtime'];
            if(date("G", $modtime) != date("G", time())) {            
               list($album,$index) = get_random_photo_id();
                              while($album->getAlbumName($index)) {
                                      list($album,$index) = get_random_photo_id();
                              }
               $blockContent = createBlockContent($album,$index,$scale);
               $fp = fopen($gallery->app->albumDir."/hourly.txt","w");
               fwrite($fp,$album->fields['name']."/".$index);
               fclose($fp);
               return $blockContent;
            }
            else {
               $fp = fopen($gallery->app->albumDir."/hourly.txt","r");
               $line = explode("/",fgets($fp));
               $albumName = $line[0];
               $album = new Album();
               $album->load($albumName);
               $index = $line[1];
               $blockContent = createBlockContent($album,$index,$scale);
               return $blockContent;
            }
         }
         else {
            list($album,$index) = get_random_photo_id();
                           while($album->getAlbumName($index)) {
                                   list($album,$index) = get_random_photo_id();
                           }
            $blockContent = createBlockContent($album,$index,$scale);
            $fp = fopen($gallery->app->albumDir."/hourly.txt","w");
            fwrite($fp,$album->fields['name']."/".$index);
            fclose($fp);
            return $blockContent;
         }
         break;
      case 24:
         if (file_exists($gallery->app->albumDir."/daily.txt")) {
            $stat=stat($gallery->app->albumDir."/daily.txt");
            $modtime = $stat['mtime'];
            if(date("d", $modtime) != date("d", time())) {            
               list($album,$index) = get_random_photo_id();
                              while($album->getAlbumName($index)) {
                                      list($album,$index) = get_random_photo_id();
                              }
               $blockContent = createBlockContent($album,$index,$scale);
               $fp = fopen($gallery->app->albumDir."/daily.txt","w");
               fwrite($fp,$album->fields['name']."/".$index);
               fclose($fp);
               return $blockContent;
            }
            else {
               $fp = fopen($gallery->app->albumDir."/daily.txt","r");
               $line = explode("/",fgets($fp));
               $albumName = $line[0];
               $album = new Album();
               $album->load($albumName);
               $index = $line[1];
               $blockContent = createBlockContent($album,$index,$scale);
               return $blockContent;
            }
         }
         else {
            list($album,$index) = get_random_photo_id();
                           while($album->getAlbumName($index)) {
                                   list($album,$index) = get_random_photo_id();
                           }
            $blockContent = createBlockContent($album,$index,$scale);
            $fp = fopen($gallery->app->albumDir."/daily.txt","w");
            fwrite($fp,$album->fields['name']."/".$index);
            fclose($fp);
            return $blockContent;
         }
         break;
   }
}

function get_random_photo_id(){
      /* Initializing the seed */
      srand ((double) microtime() * 1000000);

      readcache();

      $album = choosealbum();

      if ($album) {
         $index = choosephoto($album);
      }
      return array($album,$index);
}

function savecache($chosenArray = '') {
    global $cache;
    if($chosenArray) {
   $cache = $chosenArray;
    }
    $fd = fopen(CACHE_FILE, "w");
    foreach ($cache as $key => $val) {
   fwrite($fd, "$key/$val\n");
    }
    fclose($fd);
}

function readcache() {
    global $cache;
    if ($fd = fs_fopen(CACHE_FILE, "r")) {
      while ($line = fgets($fd, 4096)) {
         list($key, $val) = explode("/", $line);
         $cache[$key] = $val;
      }
      fclose($fd);
    }
}

function choosephoto($album) {
    global $cache, $gallery;

    $count = $cache[$album->fields["name"]];

    if ($count == 0) {
      // Shouldn't happen
      return null;
    } else if ($count == 1) {
      $choose = 1;
    } else {
      $count = floatval($count);
      $choose = rand(1, $count);
      $wrap = 0;
      if ($album->isHidden($choose)) {
         $choose++;
         if ($choose > $album->numPhotos(1)) {
            $choose = 1;
            $wrap++;
            if ($wrap = 2) {
               return null;
            }
         }
      }
    }
    return $choose;
}

function choosealbum() {
    global $cache;

    /*
     * The odds that an album will be selected is proportional
     * to the number of (visible) items in the album.
     */

    $total = 0;
    foreach ($cache as $name => $count) {
      if (!$choose) {
         $choose = $name;
      }

      $total += $count;
      if ($total != 0 && ($total == 1 || rand(1, $total) <= $count)) {
         $choose = $name;
      }
    }

    if ($choose) {
      $album = new Album();
      $album->load($choose);
      return $album;
    } else {
      return null;
    }
}

function scanalbums() {
    global $cache;
    global $gallery;

    $cache = array();
    $everybody = $gallery->userDB->getEverybody();
    $albumDB = new AlbumDB();
    foreach ($albumDB->albumList as $tmpAlbum) {
      if ($everybody->canReadAlbum($tmpAlbum)) {
         $seeHidden = $everybody->canWriteToAlbum($tmpAlbum);
         $numPhotos = $tmpAlbum->numPhotos($seeHidden);
         $name = $tmpAlbum->fields["name"];
         if ($numPhotos > 0) {
            $cache[$name] = $numPhotos;
         }
      }
    }
}

function createAdminList($albumName,$depth=0){
        global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_MODULENAME;

        $printedHeader = 0;
        $myAlbum = new Album();
        $myAlbum->load($albumName);
        $numPhotos = $myAlbum->numPhotos(1);
        for ($i=1; $i <= $numPhotos; $i++) {
                $myName = $myAlbum->getAlbumName($i);
                if ($myName && !$myAlbum->isHidden($i)) {
                        $nestedAlbum = new Album();
                        $nestedAlbum->load($myName);
                        if ($gallery->user->canReadAlbum($nestedAlbum)) {
                                $val2 = $nestedAlbum->fields['title'];
            $photoCount = $nestedAlbum->numPhotos(1);
                                $content .= "<div style=\"margin: 0px 0px 0px 20px\">";
                                $content .= "<span class=fineprint>";
            $content .= "<input type=\"checkbox\" value=\"$photoCount\" name=\"$albumName\">";
                                $content .= "<a href=\"";
                                $content .= makeAlbumUrl($myName);
                                $content .= "\">$val2</a>\n";
                                $content .= createAdminList($myName,$depth+1);
                                $content .= "</span>";
                                $content .= "</div>";
                        }
                }
        }
        return $content;
}

?>

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Oct 11, 2005 7:00 am
did you create the cache file when you installed the block and are still getting this error?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
racer25
Joined: Jul 22, 2004
Posts: 21

Posted: Tue Oct 11, 2005 7:29 am
No I didn't manually craete a cache file. Forgive me if I missed it in the README but I can't see that part at all.

How would I do that, is just a blank file and what permissions do I need etc.

Thanks in advance.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
racer25
Joined: Jul 22, 2004
Posts: 21

Posted: Tue Oct 11, 2005 7:55 am
Actually got the menu up to select the blocks but now get the following error message

Error: Requested index [2] out of bounds [1]
Fatal error: Call to a member function on a non-object in /home/keller/public_html/modules/gallery/classes/Album.php on line 1250

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
racer25
Joined: Jul 22, 2004
Posts: 21

Posted: Fri Oct 14, 2005 2:34 am
Anyone ?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
Kurse
Joined: Sep 30, 2003
Posts: 2

Posted: Tue Dec 13, 2005 1:23 pm
I tried this block, and it does ask me which albums I want to display, but even after the selection it repeatedly asks again. It doesnt seem to be able to save the selection.

Just a suggestion: Maybe it would be easier to make it select what you do NOT want to display, I would think the list would be smaller that way.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Sat Dec 31, 2005 6:46 am
Hi Dari,

A quick question regarding the Selectable Block. I wish to hardcode the block to select only one ALBUM to pull images from. I want to remove the part that lists the albums (if logged in as admin). I have already done it on the newest block - just can't get my head round the random one. Can you steer me in the right direction?

Cheers

Happy 2006.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Sat Dec 31, 2005 8:24 am
sure thing, let me catch up to the 150 posts i've missed over the week and i'll post the modification here Smile

happy 2k6 Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Sat Dec 31, 2005 9:12 am
just create a cache file (block-random.cache) in your albums directory (rename it if you want to use another name to resolve conflicts, but make sure you fix the "define" statements in the block files) and add this to it:
Code: › <album_name>/<number_of_photos_in_album>

note that it's the name of the album, not the title (ie, christmaspix2005). and don't forget the slash....

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Sat Dec 31, 2005 11:25 am
Thx however - I will still need the block to update the amount of photo's in the album (when new ones added).

Currently I have amended the script to create a NEW unique cache file (albumname.cache) and save in to the ALBUMS folder. Works great with the 'newest' block. Just need to be able to specify the album name in the random block (currently using the selectable ver.) and for it to 'rebuild' the cache file (update amount of images in the album) periodically.

Is it something around the scanalbum function? Can the album it scans be hardcoded?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Jan 03, 2006 2:15 pm
gotcha. do you know what albums they will be? will they ever change, or will it be a static list?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Tue Jan 10, 2006 4:40 pm
Oops - missed ya post.

Yep - static list. New albums are added though but all references are controlled via MySQL (i.e. new album is created, then it's name is entered in to a custom mysql for use in different areas).

I just need to be able to 'insert' in to your code the album I want it to pick photos from and for it to update the cache for that album (already done via unique cache files). Perhaps if a variable is defined at the top then used throughout - I will then control the variable externally.

Any of that make sense!!!

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Jan 10, 2006 5:34 pm
yep, i'll get on it.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Mon Jan 23, 2006 2:41 pm
bump.

Just point me in the right direction - if it's easier Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Wed Jan 25, 2006 8:45 am
i've been looking at it, and i'm trying to figure out the best spot in which to put an array of album names...which, in your case, would also trim out a lot of excess code (ie, you wouldn't need "scanalbums" or "savecache", etc)....

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Sat Feb 04, 2006 9:16 pm
Still no luck?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Thu Feb 23, 2006 5:56 pm
Bump. Is there anyone else I can take this problem to?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Feb 24, 2006 8:17 am
sorry, kinda got sidetracked w/ the 2.1 release. i should have some time this weekend to take a look at this.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Fri Feb 24, 2006 8:19 am
Appreciate it Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Fri Mar 03, 2006 2:20 am
Dari if you don't have the time or are unable to help can you please let me know so I can sort it another way - many thanks

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
menelaos61
Joined: Mar 23, 2005
Posts: 3

Posted: Fri Mar 03, 2006 3:30 am
Hi guys,
To indicate in the block-file from which album the block must derive it's pictures, just add:

Code: › 'itemId'=>1234


to the block-code (1234 would have to correspond with the album code of choice)

so find the piece of code like:
Code: › list($ret,$html, $head) = GalleryEmbed::getImageBlock(array('blocks'=>$blockType,'show'=>$display,'itemFrame'=>'solid','albumFrame'=>'solid','maxSize' => $maxSize));


and replace it with something like:
Code: › list($ret,$html, $head) = GalleryEmbed::getImageBlock(array('blocks'=>$blockType,'show'=>$display,'itemId'=>1234,'itemFrame'=>'solid','albumFrame'=>'solid','maxSize' => $maxSize));


Remember to find out the itemId number of the album of your choice...

This method works fabulously Smile

Cheers,
Richard (menelaos61)

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Mar 03, 2006 7:32 am
slackbladder wrote: › Dari if you don't have the time or are unable to help can you please let me know so I can sort it another way - many thanks


actually, after hacking away at the selectable block file, i realized that since you want to hardcode in the values of albums, that the normal random block file is what you should use.

try:
PHP: › <?php

/* 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Developed by Dariush Molavi at NukedGallery.net
 * Version 2.0
 * 13 December 2003
 */

 
if (eregi("block-NG-RandomPhoto_functions.php",$_SERVER['PHP_SELF'])) {
    
Header("Location: index.php");
    die();
}

global 
$gallery$GALLERY_EMBEDDED_INSIDE$GALLERY_EMBEDDED_INSIDE_TYPE$GALLERY_MODULENAME$Version_Num;

/*******************************************************************/
/* Full path to your Gallery, don't forget the trailing /          */
/*******************************************************************/
$GALLERY_BASEDIR "/home/httpd/phpnuke.nukedgallery.net/htdocs/modules/gallery/";

/*******************************************************************/
/* The module name of your Gallery, default is "gallery"           */
/*******************************************************************/
$GALLERY_MODULENAME "gallery";

/*******************************************************************/
/* Time, in seconds, to refresh random photo cache. Default is     */
/* 86400 (check it daily)                                          */
/*******************************************************************/
define(CACHE_EXPIRED10);

/*******************************************************************/
/* Full path to your albums directory, don't forget the trailing / */
/*******************************************************************/
define(ALBUM_DIRECTORY,"/home/httpd/phpnuke.nukedgallery.net/htdocs/albums/");



/*******************************************************************/
/*          STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT           */
/*******************************************************************/
define(CACHE_FILEALBUM_DIRECTORY."block-random.cache");

$GALLERY_EMBEDDED_INSIDE "nuke";
$GALLERY_EMBEDDED_INSIDE_TYPE "phpnuke";

require_once(
$GALLERY_BASEDIR "init.php");

function 
createBlockContent($album,$index,$scale,$auto=0) {
    global 
$gallery$GALLERY_EMBEDDED_INSIDE$GALLERY_EMBEDDED_INSIDE_TYPE$GALLERY_MODULENAME;

    
$id $album->getPhotoId($index);
    
$caption $album->getCaption($index);
    
$photo $album->getPhoto($index);
    
$dir $album->getAlbumDirURL("full");
    
$image $photo->image;
    
$PHOTO_URL makeAlbumUrl($album->fields['name'], $id);
    
$ALBUM_URL makeAlbumUrl($album->fields['name']);
    if(
$scale == 0) {
                        if(
$auto == 0) {
                                
$IMG "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index)."</a><br>";
                        }
                        else {
                                
$IMG "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index)."</a><br>";
                        }
    } else {
                        if(
$auto == 0) {
                                
$IMG "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
                        else {
                                
$IMG "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
    }
    
$FROM "From: <a href=\"$ALBUM_URL\">" $album->fields['title'] . '</a>';
    
$blockContent .=  "\t$IMG\n";
    
$blockContent .= "\t$caption<br />\n";
    
$blockContent .= "\t$FROM\n</center>";
    return 
$blockContent;
}

function 
get_photo($interval$scale,$auto=0) {
    global 
$gallery$GALLERY_EMBEDDED_INSIDE$GALLERY_EMBEDDED_INSIDE_TYPE$GALLERY_MODULENAME;

    switch (
$interval) {
        case 
0:
            list(
$album,$index) = get_random_photo_id();
            while(
$album->getAlbumName($index)) {
                list(
$album,$index) = get_random_photo_id();
            }
            
$blockContent createBlockContent($album,$index,$scale,$auto);
            return 
$blockContent;
            break;
        case 
1:
            if (
file_exists($gallery->app->albumDir."/hourly.txt")) {
                
$stat=stat($gallery->app->albumDir."/hourly.txt");
                
$modtime $stat['mtime'];
                if(
date("G"$modtime) != date("G"time())) {                
                    list(
$album,$index) = get_random_photo_id();
                                while(
$album->getAlbumName($index)) {
                                        list(
$album,$index) = get_random_photo_id();
                                }
                    
$blockContent createBlockContent($album,$index,$scale);
                    
$fp fopen($gallery->app->albumDir."/hourly.txt","w");
                    
fwrite($fp,$album->fields['name']."/".$index);
                    
fclose($fp);
                    return 
$blockContent;
                }
                else {
                    
$fp fopen($gallery->app->albumDir."/hourly.txt","r");
                    
$line explode("/",fgets($fp));
                    
$albumName $line[0];
                    
$album = new Album();
                    
$album->load($albumName);
                    
$index $line[1];
                    
$blockContent createBlockContent($album,$index,$scale);
                    return 
$blockContent;
                }
            }
            else {
                list(
$album,$index) = get_random_photo_id();
                            while(
$album->getAlbumName($index)) {
                                    list(
$album,$index) = get_random_photo_id();
                            }
                
$blockContent createBlockContent($album,$index,$scale);
                
$fp fopen($gallery->app->albumDir."/hourly.txt","w");
                
fwrite($fp,$album->fields['name']."/".$index);
                
fclose($fp);
                return 
$blockContent;
            }
            break;
        case 
24:
            if (
file_exists($gallery->app->albumDir."/daily.txt")) {
                
$stat=stat($gallery->app->albumDir."/daily.txt");
                
$modtime $stat['mtime'];
                if(
date("d"$modtime) != date("d"time())) {                
                    list(
$album,$index) = get_random_photo_id();
                                while(
$album->getAlbumName($index)) {
                                        list(
$album,$index) = get_random_photo_id();
                                }
                    
$blockContent createBlockContent($album,$index,$scale);
                    
$fp fopen($gallery->app->albumDir."/daily.txt","w");
                    
fwrite($fp,$album->fields['name']."/".$index);
                    
fclose($fp);
                    return 
$blockContent;
                }
                else {
                    
$fp fopen($gallery->app->albumDir."/daily.txt","r");
                    
$line explode("/",fgets($fp));
                    
$albumName $line[0];
                    
$album = new Album();
                    
$album->load($albumName);
                    
$index $line[1];
                    
$blockContent createBlockContent($album,$index,$scale);
                    return 
$blockContent;
                }
            }
            else {
                list(
$album,$index) = get_random_photo_id();
                            while(
$album->getAlbumName($index)) {
                                    list(
$album,$index) = get_random_photo_id();
                            }
                
$blockContent createBlockContent($album,$index,$scale);
                
$fp fopen($gallery->app->albumDir."/daily.txt","w");
                
fwrite($fp,$album->fields['name']."/".$index);
                
fclose($fp);
                return 
$blockContent;
            }
            break;
    }
}

function 
get_random_photo_id(){
        
/* Initializing the seed */
        
srand ((double) microtime() * 1000000);

        
readcache();
        
$album choosealbum();

        if (
$album) {
            
$index choosephoto($album);
        }
        return array(
$album,$index);
}


function 
readcache() {
    global 
$cache;

    
$cache = array('album_name'=>'num_photos''album_2'=>'num_photos');

}

function 
choosephoto($album) {
    global 
$cache$gallery;

    
$count $cache[$album->fields["name"]];

    if (
$count == 0) {
        
// Shouldn't happen
        
return null;
    } else if (
$count == 1) {
        
$choose 1;
    } else {
        
$count floatval($count);
        
$choose rand(1$count);
        
$wrap 0;
        if (
$album->isHidden($choose)) {
            
$choose++;
            if (
$choose $album->numPhotos(1)) {
                
$choose 1;
                
$wrap++;
                if (
$wrap 2) {
                    return 
null;
                }
            }
        }
    }
    return 
$choose;
}

function 
choosealbum() {
    global 
$cache;

    
/*
     * The odds that an album will be selected is proportional
     * to the number of (visible) items in the album.
     */

    
$total 0;
    foreach (
$cache as $name => $count) {
        if (!
$choose) {
            
$choose $name;
        }

        
$total += $count;
        if (
$total != && ($total == || rand(1$total) <= $count)) {
            
$choose $name;
        }
    }

    if (
$choose) {
        
$album = new Album();
        
$album->load($choose);
        return 
$album;
    } else {
        return 
null;
    }
}

?>


note that in the readcache function, you'll need the album name and the number of photos in the album (the randomizer uses the number of photos to determine how often to pull from that album).

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Mar 03, 2006 7:33 am
menelaos61 wrote: › Hi guys,
To indicate in the block-file from which album the block must derive it's pictures, just add:

Code: › 'itemId'=>1234


to the block-code (1234 would have to correspond with the album code of choice)

so find the piece of code like:
Code: › list($ret,$html, $head) = GalleryEmbed::getImageBlock(array('blocks'=>$blockType,'show'=>$display,'itemFrame'=>'solid','albumFrame'=>'solid','maxSize' => $maxSize));


and replace it with something like:
Code: › list($ret,$html, $head) = GalleryEmbed::getImageBlock(array('blocks'=>$blockType,'show'=>$display,'itemId'=>1234,'itemFrame'=>'solid','albumFrame'=>'solid','maxSize' => $maxSize));


Remember to find out the itemId number of the album of your choice...

This method works fabulously Smile

Cheers,
Richard (menelaos61)


this works for G2, but slackbladder is enquiring about G1 Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Fri Mar 03, 2006 7:35 am
Hi Dari,

Does the 'hacked' block create / re-build the cache file (so new photo's when added to the album are also added to the cache i.e. the cache number increases)?

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Fri Mar 03, 2006 7:39 am
no, this is a quick and dirty hack. it doesn't use a cache file at all, just an array that you populate with your albums by hand (i thought that's what you wanted)...however, updating the array with the proper values shouldn't be too hard...

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
slackbladder
Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK
Posted: Fri Mar 03, 2006 7:46 am
What I am after (and have it working just about using the selectable block) is:

From the block code I can select (hard code) an album from which the random block pulls an image from.

I currently use a different 'cache' file for each album (e.g. album1-random.cache, album2-random.cache)

I need for the code to rebuild each seperate cache, using it's hardcoded album images.

The reason all this is that I have built a site (music) that has sections dedicated to different artists, each artist has a section the gallery for his photos.

Please review:

http://www.classicalx.com

then an artist page:

http://www.classicalx.com/Andrea_Bocelli.html

Random block is on the left.

Many thanks for the help Smile

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
LuckyMcGee
Joined: Jan 17, 2006
Posts: 17

Posted: Sat Jun 17, 2006 2:17 am
I'm getting MySQL errors when attempting to use it with Gallery2. Confused

[edit] If this is only for Gallery1, is there a way to eliminate certain albums from displaying in the random photo block in G2?? [/edit]

Thanks!

Errors received:

Code: › Warning: main(/home/.alonso/xxxx/the152.com/modules/gallery2/init.php): failed to open stream: No such file or directory in /home/.alonso/xxxx/the152.com/NG-RandomPhotoSelectTest_functions.php on line 61

Fatal error: main(): Failed opening required '/home/.alonso/xxxx/the152.com/modules/gallery2/init.php' (include_path='.:/usr/local/lib/php') in /home/.alonso/xxxx/the152.com/NG-RandomPhotoSelectTest_functions.php on line 61

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Sat Jun 17, 2006 7:44 am
that block is only for g1. you can via album properties in g2, "hide" the album from imageblock.

AuthorMessage
Post Title: Re: [TESTING] Selectable Album Random Block
LuckyMcGee
Joined: Jan 17, 2006
Posts: 17

Posted: Tue Jun 20, 2006 6:29 pm
I hate when I post, and then find the answer 2 seconds later. Embarassed Laughing

All times are GMT - 5 Hours
Powered by PHPNuke and phpBB2 © 2006 phpBB Group