open includes\acp\acp_medals.phpfemu wrote:Hi,
I'm wondering, if it's possible to sort the image names list in the ACP, when adding or editing medals. I just found the solution for another mod, but this won't work here, as the way of reading the medals directory is different solved (in the other one, the file names were read into an array and the array simply can be sorted using sort($array) ).
It would be really great to have them sorted here too, as it's painful to find the correct image, if you have a lot of them![]()
Thanks,
femu
FIND
Code: Select all
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (strlen($file) >= 3 && ( strpos($file, '.gif',1) || strpos($file, '.jpg',1) || strpos($file, '.png',1) ))
{
$options .= '<option value="' . $file . '">' . $file . '</option>';
}
}
closedir($dh);
}
Code: Select all
$dirfile = array();
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (strlen($file) >= 3 && ( strpos($file, '.gif',1) || strpos($file, '.jpg',1) || strpos($file, '.png',1) ))
{
array_push($dirfile,"$file");
}
}
closedir($dh);
}
natsort($dirfile);
foreach ($dirfile as $key => $value)
{
$options .= '<option value="' . $value . '">' . $value . '</option>';
}
FIND
Code: Select all
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (strlen($file) >= 3 && ( strpos($file, '.gif',1) || strpos($file, '.jpg',1) || strpos($file, '.png',1) ))
{
if ($medals[$medal_id]['image'] == $file)
{
$options .= '<option value="' . $file . '" selected="selected">' . $file . '</option>';
}
else
{
$options .= '<option value="' . $file . '">' . $file . '</option>';
}
}
}
closedir($dh);
}
Code: Select all
$dirfile = array();
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (strlen($file) >= 3 && ( strpos($file, '.gif',1) || strpos($file, '.jpg',1) || strpos($file, '.png',1) ))
{
array_push($dirfile,"$file");
}
}
closedir($dh);
}
natsort($dirfile);
foreach ($dirfile as $key => $value)
{
if ($medals[$medal_id]['image'] == $value)
{
$options .= '<option value="' . $value . '" selected="selected">' . $value . '</option>';
}
else
{
$options .= '<option value="' . $value . '">' . $value . '</option>';
}
}