We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Did you upgrade the Tiny MCE version as well?
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 15065
      • 138 Posts
      Hi
      I upgraded TinyMCE also, But still got the folders as earlier ( not sorted and like the screen shot above - imagebrowserwindow.jpg ) .
      You can login into my site http://redbusiness.comeleonwebtest.info/manager/
      using username: admin,  password : admin123

      there is anything to add / change settings ?

      pls help me

      thanks & regards

      Jurdy
      • Thank you for the update and login Jurdy. We’ll continue to dig further and get back to you ASAP.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 15065
          • 138 Posts
          Hi
          I tried in my local server. My MODx ver is 0.9.6 and my TinyMCE ver is 2.1.1.1 . With  this cofiguration all the folders are arranged in its create/modify order.
          But when I upgraded only my TinyMCE to 2.1.1.2 , I got all the folders and files in alphabetical order. [ I GOT ONLY IN MY LOCAL HOST, IN ACTUAL SERVER , PROBLEM IS NOT SOLVED]

          thers is anything related to server settings ? my localhost phpinfo is attached with this.

          Hoping this post will help you for your checking.

          thanks & regards

          Jurdy
            • 28436
            • 242 Posts
            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 smiley

            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"
            • Nice work, Stefan! smiley I’ll check the code out. If it works okay, I’ll get it committed for the 0.9.6.2 release!

              Thanks,
              Garry
                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com
                • 28436
                • 242 Posts
                Hello Garry,
                thank you!

                At the last days i begun to check out some filebrowsers, specially those with a ftp-wrapper. this would be a great feature for peoples like me with a php-as-modul-installation. At the moment i try to merry some of them with tinyMCE. But.... iam a rookie... is something like that planed for a further version of modx?

                Thankk you and have a nice day!
                adios, Stefan
                  • 15065
                  • 138 Posts
                  Thanks for your help.
                  Now I got folders and files in alphabetical order.[ 0-9 /A-Z/ a-z order ]


                  thanks & regards

                  Jurdy

                    • 28436
                    • 242 Posts
                    Hello jurdy,

                    to perform a "natural sort" replace the three "sort"s with "natcasesort" . Guess this will be smarter. take a look to the exampes at http://php.net/natcasesort

                    hasta luego
                    Stefan
                      • 15065
                      • 138 Posts
                      Hi stefan

                      That works well. Now I got all the files and folders in alphabetical order.

                      Thank you so much for your help.

                      Thanks & Regards

                      Jurdy