[MOD RELEASE] Alpha...
 
Notifications
Clear all

[MOD RELEASE] Alpha Sort "Manage Images" page

4 Posts
2 Users
0 Reactions
1,516 Views
(@piper)
Posts: 91
Trusted Member
Topic starter
 

Description: This is a simple modification that "Alphabetically Sorts" the images on the "Manage Images" user page. I did this because I find, that it's much easier to find things when there is some kind of rhyme/reason to their existence.

Requirements: eFiction 3.x

Mod History: Initial Release

On or about line 206 change :

               while($filename = readdir($directory)) {

To :

                $files = array();
                while($files[] = readdir($directory)) {
                sort($files);
                }
                foreach ($files as $filename){

This Mod currently sorts based on file names, 0-9, then A-Z ,then a-z. if you wish to reverse the sort order,

Just change :

                sort($files)

To :

                rsort($files)

Hope this helps someone, if not, well it was worth it for my own sanity! -giggles-
-P/KAF/PT


StoryPortal Fiction Network - StoryPortal.Net
TG Fiction dot NET | T* Fiction Archive - TGFiction.Net
LG Tales | TG Style Fiction for LG's - LGTales.Com

 
Posted : 19/02/2011 5:51 pm
(@tammy)
Posts: 2577
Member Moderator
 

You forgot to tell them what file to change.  The file to be changed is user/manageimages.php

And that's not how you should do it. As you've written it, you're sorting the files array every time you add a file to the array.  You should do it like this:


$files = array();
while($filename = readdir($directory)) {
if($filename=="." || $filename==".." || $filename == "imagelist.js") continue;
$files[] = $filename;
}
sort($files);
foreach($files AS $filename) {
list($imght, $imgwth, $type, $attr) = getimagesize("$folder/$filename");
$output .= "<tr><td class='tblborder'>$filename</td><td class='tblborder'>&#60;img src=""$folder/$filename"&#62;</td><td" class='tblborder' style='text-align: center;'><a href=""javascript:pop('$folder/$filename'," $imgwth, $imght, 'yes')">"._VIEW."</a> | <a href=""user.php?action=manageimages&amp;delete=$filename"" onclick="return confirm('"._CONFIRMDELETE."')">"._DELETE."</a></td></tr>";
$count++;
}

This puts the files into the array $files skipping the listings we don't want, then sorts the array once after all the files are added.


 
Posted : 20/02/2011 1:04 pm
(@piper)
Posts: 91
Trusted Member
Topic starter
 

You forgot to tell them what file to change.  The file to be changed is user/manageimages.php

And that's not how you should do it. As you've written it, you're sorting the files array every time you add a file to the array.  You should do it like this:


$files = array();
while($filename = readdir($directory)) {
if($filename=="." || $filename==".." || $filename == "imagelist.js") continue;
$files[] = $filename;
}
sort($files);
foreach($files AS $filename) {
list($imght, $imgwth, $type, $attr) = getimagesize("$folder/$filename");
$output .= "<tr><td class='tblborder'>$filename</td><td class='tblborder'>&#60;img src=""$folder/$filename"&#62;</td><td" class='tblborder' style='text-align: center;'><a href=""javascript:pop('$folder/$filename'," $imgwth, $imght, 'yes')">"._VIEW."</a> | <a href=""user.php?action=manageimages&amp;delete=$filename"" onclick="return confirm('"._CONFIRMDELETE."')">"._DELETE."</a></td></tr>";
$count++;
}

This puts the files into the array $files skipping the listings we don't want, then sorts the array once after all the files are added.

You are very much right, I typo-ed that one.

As a side note, the same process can be put towards alpha sorting the imagelist.js which apparently is recreated every time a file is added correct?

-P/KAF/PT


StoryPortal Fiction Network - StoryPortal.Net
TG Fiction dot NET | T* Fiction Archive - TGFiction.Net
LG Tales | TG Style Fiction for LG's - LGTales.Com

 
Posted : 21/02/2011 4:48 am
(@tammy)
Posts: 2577
Member Moderator
 

Correct.


 
Posted : 21/02/2011 10:15 am
Share: