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 -
TG Fiction dot NET | T* Fiction Archive -
LG Tales | TG Style Fiction for LG's -
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'><img src=""$folder/$filename"></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&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 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'><img src=""$folder/$filename"></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&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 -
TG Fiction dot NET | T* Fiction Archive -
LG Tales | TG Style Fiction for LG's -
Correct.
