Hello Guys, hello Jurdy!
i can confirm the behavior (modx 961, rte 212) and can provide a solution.
Jurdy, you are on the right way with sorting an array, but at first you _need_ an array to sort
GetFolders.php
<Folders>
<?php
if ($dh=opendir($this->real_cwd)) {
/**
* Initiate the array to store the filenames
*/
$files_in_folder = array();
while (($filename=readdir($dh))!==false) {
if (($filename!=".")&&($filename!="..")) {
if (is_dir($this->real_cwd."/$filename")) {
//check if$fckphp_configured not to show this folder
$hide=false;
for($i=0;$i<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders']);$i++)
$hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders'][$i],$filename)?true:$hide);
/**
* Dont echo the entry, push it in the array
*/
//if (!$hide) echo "<Folder name=\"$filename\" />\n";
if (!$hide) array_push($files_in_folder,$filename);
}
}
}
closedir($dh);
}
/**
* Sort the array by the way you like and show it.
*/
sort($files_in_folder);
foreach($files_in_folder as $k=>$v)
{
echo '<Folder name="'.$v.'" />'."\n";
}
?>
</Folders>
And "same same but different" in getFoldersAndFiles.php
$files=array();
if ($dh=opendir($this->real_cwd)) {
/**
* Initiate the array to store the foldernames
*/
$folders_array = array();
while (($filename=readdir($dh))!==false) {
if (($filename!=".")&&($filename!="..")) {
if (is_dir($this->real_cwd."/$filename")) {
//check if$fckphp_configured not to show this folder
$hide=false;
for($i=0;$i<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders']);$i++)
$hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders'][$i],$filename)?true:$hide);
/**
* Dont echo the entry, push it in the array
*/
//if (!$hide) echo "\t\t<Folder name=\"$filename\" />\n";
if (!$hide) array_push($folders_array,$filename);
} else {
array_push($files,$filename);
}
}
}
closedir($dh);
/**
* Sort the array by the way you like and show it.
*/
sort($folders_array);
foreach($folders_array as $k=>$v)
{
echo '<Folder name="'.$v.'" />'."\n";
}
}
echo "\t</Folders>\n";
echo "\t<Files>\n";
/**
* The filenames are in the array $files
* SORT IT!
*/
sort($files);
for ($i=0;$i<sizeof($files);$i++) {
$lastdot=strrpos($files[$i],".");
$ext=(($lastdot!==false)?(substr($files[$i],$lastdot+1)):"");
if (in_array(strtolower($ext),$this->fckphp_config['ResourceAreas'][$this->type]['AllowedExtensions'])) {
//check if$fckphp_configured not to show this file
$editable=$hide=false;
for($j=0;$j<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFiles']);$j++)
$hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFiles'][$j],$files[$i])?true:$hide);
if (!$hide) {
if ($this->fckphp_config['ResourceAreas'][$this->type]['AllowImageEditing'])
$editable=$this->isImageEditable($this->real_cwd."/".$files[$i]);
echo "\t\t<File name=\"".htmlentities($files[$i])."\" size=\"".ceil(filesize($this->real_cwd."/".$files[$i])/1024)."\" editable=\"" . ( $editable?"1":"0" ) . "\" />\n";
}
}
}
echo "\t</Files>\n";
echo "</Connector>\n";
Do you think some other people can use this as well? please beautfiy the coding an post it at a public place. I dont have the abilities to do that... iam a bloody fucking rookie... :-(
have a nice day!
ciao, Stefan
// Edit: its better to use "natcasesort" instead of "sort"